Home Download Buy Blog Forum Support

Customizing ctrl+click

Re: Customizing ctrl+click

Postby adzenith on Mon Jun 25, 2012 6:34 pm

xeno.by wrote:
adzenith wrote:Ah I see! run_ (with an underscore) strips the event from the arguments list before calling run (no underscore). So you have to override run_ instead of overriding run.
Awesome.

Woot! What's the difference between run and run_?

That's the entire difference right there. run doesn't get the event.
adzenith
 
Posts: 1217
Joined: Mon Oct 19, 2009 9:12 pm

Re: Customizing ctrl+click

Postby quodlibet on Tue Jun 26, 2012 10:19 pm

adzenith wrote:The mouse-callback thing is not yet integrated into my ScrollOff plugin, which may have explained what you were seeing.


I wasn't clear, sorry. I tried the Scroll Off plugin and the mouse stuff separately (one after the other). If the latter only works with the former, then that's why I didn't see any effect. Or maybe I still don't understand what it's supposed to do.

My plan was to capture on_pre_click, disable ScrollOff for the next on_selection_modified, then capture on_post_click and re-enable. This would make it so that clicking wouldn't scroll the display, allowing normal selections with the mouse. Does that make sense?


Sort of. (I'm not a programmer and your explanation is a little technical.) I'll keep an eye out for what you're building and see if it might work for me also, although probably not out of the box.

In the meantime I would be quite happy with just disabling the mouse (or, at least, button 1) altogether when my plugin is enabled, but "context" seems to be ignored in mousemaps. Darn.
quodlibet
 
Posts: 561
Joined: Sat Jun 18, 2011 5:53 pm

Re: Customizing ctrl+click

Postby adzenith on Wed Jun 27, 2012 6:56 pm

I just pushed my changes. Try installing both ScrollOffset and MouseEventListener and tell me if you like what you see.
adzenith
 
Posts: 1217
Joined: Mon Oct 19, 2009 9:12 pm

Re: Customizing ctrl+click

Postby quodlibet on Thu Jun 28, 2012 9:15 pm

You should put something in the README about the fact that ScrollOffset only works when word wrap is off :?

ScrollOffset looks like a plugin I might well use (for coding, which is a different situation than the one I've been talking about).

As for using MouseEventListener with my typewriter plugin, I didn't manage to get anything particularly useful done.

I've thrown up the plugin below, if you don't mind having a look. (But I don't mean to impose.)

Code: Select all
import sublime, sublime_plugin

class AlwaysCenterCommand(sublime_plugin.EventListener):
   def on_selection_modified(self, view):
      if view.settings().get('typewriter_mode') == 1:
         sel = view.sel()
         region = sel[0] if len(sel) == 1 else None
         if region != None:
            view.show_at_center(region)


The plugin keeps the cursor always centered. What I've been hoping to do is to prevent is extending the selection with mouse clicking. Is this possible?

Again, feel free to ignore this stuff.
quodlibet
 
Posts: 561
Joined: Sat Jun 18, 2011 5:53 pm

Re: Customizing ctrl+click

Postby adzenith on Fri Jun 29, 2012 9:08 pm

I guess I never use word wrap... Maybe I should look into why it doesn't work.

I'd install MouseEventListener, then in your AlwaysCenterCommand add this:
Code: Select all
   ignore_count = 0
   def on_pre_mouse_down(self, args):
      self.ignore_count = 3
   def on_post_mouse_down(self, click_point):
      self.ignore_count = 1


Then inside of on_selection_modified, throw this at the top:
Code: Select all
      if self.ignore_count:
         self.ignore_count -= 1
         return


Lemme know if that works.
adzenith
 
Posts: 1217
Joined: Mon Oct 19, 2009 9:12 pm

Re: Customizing ctrl+click

Postby tito on Fri Jun 29, 2012 9:43 pm

typewriter_mode was added to bufferscroll, did you have some problem with this plugin? I want to fix it, if that is the case.

REgars,
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 876
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: Customizing ctrl+click

Postby quodlibet on Fri Jun 29, 2012 11:03 pm

Hi @tito,

I am not using your BufferScroll plugin, so there isn't anything related to that for you to fix. If you're offering your excellent services though....... ;)

I am using the plugin I posted above; it's slightly modified from something @facelessuser has written[1]. This plugin activates on "on_selection_modified" rather than "on_modified" (as is the case with BufferScroll). This means that the screen is scrolled every time the cursor changes position,which works great when you are:

a) writing prose rather than code,
b) using the keyboard rather than the mouse

Unfortunately, the functionality of the mouse is quite broken: it's too easy to select text when trying to position the cursor. I haven't actually used iA Writer[2], but it disables the mouse completely, I suspect for this reason.

I actually rather like how it works, if only I could disable extending the selection on mouse click.

[1]: viewtopic.php?f=6&t=4806
[2]: http://www.iawriter.com/
quodlibet
 
Posts: 561
Joined: Sat Jun 18, 2011 5:53 pm

Re: Customizing ctrl+click

Postby tito on Sat Jun 30, 2012 12:13 am

I understand, I'll take a look after lunch, I'm interested into providing better behaviour for these features.
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 876
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Previous

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests