sublime_text icon indicating copy to clipboard operation
sublime_text copied to clipboard

Mousemap contexts

Open iamntz opened this issue 12 years ago • 8 comments
trafficstars

I just realized that mousemaps lacks some of the keybinding goodies, like context.

E.g.:

  {
    "button": "button1", "count": 1, "modifiers": ["button2"],
    "press_command": "fold",
    "context": [
      { "key": "selection_empty", "operator": "not_equal", "operand": true, "match_all": true }
    ]
  }

Also the middle button doesn't allow count:

{
    "button": "button3", "count": 2,
    "press_command": "unfold"
}

Assuming this will be fixed someday, does anyone has an idea how to detect if a text is folded or not?

(also, there is nothing in the documentation about mouse configs; at all!)

iamntz avatar Jul 18 '13 08:07 iamntz

"Official" statement: http://www.sublimetext.com/forum/viewtopic.php?f=6&t=3311

Unfortunately, mousemap bindings don't support contexts at the moment though.

Interesting read/workaround idea: http://www.sublimetext.com/forum/viewtopic.php?f=6&t=11680

Regarding folded text: http://www.sublimetext.com/forum/viewtopic.php?f=6&t=10503

And yes, the docs suck.

FichteFoll avatar Jul 18 '13 13:07 FichteFoll

Thanks for the links. The workaround is more or less how i imagined. I'll see what i can do with this.

:-1: for the docs.

iamntz avatar Jul 18 '13 17:07 iamntz

Please, please, please allow mousemap files to provide context! I have 2 plugins that I've added double-click support to (CscopeSublime and Git) to and have had to back it out of both of them because there's no way to provide a context for mouse events.

vanrijn avatar Jul 19 '13 16:07 vanrijn

Any update on this? Would love to get more customisable mouse maps.

AndreasBackx avatar Feb 24 '17 00:02 AndreasBackx

We've been asking for this for 4 years now =:( Can we please get at least an update?

vanrijn avatar Aug 08 '17 15:08 vanrijn

This got my upvote 👍 !

Specifically for running commands when hitting specific selector, I use this little wrapper command. Just drop the mousemap_wrapper.py file in your Sublime User folder to "install".

This lets me pipe my commands through like so:

{ "button": "button1", "modifiers": ["ctrl"], "command": "mousemap_wrap",
  "press_command": "drag_select", "args": { "commands": [
    {
        "command": "anaconda_goto",
        "run_for_selector": "source.python"
    },
    {
        "command": "goto_definition",
    }
]}}

asfaltboy avatar Sep 04 '17 18:09 asfaltboy

This.

Also it would be great if mousemaps could be exposed via the Preferences menu like keymaps are

anentropic avatar Oct 04 '17 15:10 anentropic

Contexts in mousemap files would indeed allow to make useful things.

themilkman avatar Jul 05 '22 09:07 themilkman

The "context" key for mousemaps was added in build 4149.

BenjaminSchaaf avatar May 04 '23 01:05 BenjaminSchaaf

:tada: Does it support the same keys as key bindings?

FichteFoll avatar May 04 '23 09:05 FichteFoll

@FichteFoll the context is derived from the position of the mouse rather than the focused control but is otherwise identical.

BenjaminSchaaf avatar May 04 '23 10:05 BenjaminSchaaf