Sublime Forum

Get active caret

#1

If you click a position i.e: (20, 20), then ctrl+click a forwardward position i.e (50, 50), then self.view.sel()[0] always return the earlier i.e: (20, 20)
=> cannot use self.view.sel()[0] to return the active caret
This is due to self.view.sel() always returned sorted region.

Any way I can get the active caret in case ctrl+click all over the place?

P.S: of course self.view.sel()-1] not work either

0 Likes

#2

All carets are always active, so this doesn’t really make sense.

0 Likes

#3

It matters when ctrl+double click.
I set ctrl+double click on text.external.link to launch hyper link.

0 Likes

#4

I suppose you have to find the clicked position by yourself using x and y argument of your command:

{ "button": "button1", "count": 2, "modifiers": "ctrl"], "press_command": "test" } ]

command: test {"event": {"button": 1, "x": 462.5, "y": 68.5}}
0 Likes

#5

I suppose you’re talking about https://github.com/SublimeText/MouseEventListener. Unfortunately, it doesn’t work for ST3.

0 Likes

#6

Nope, I didn’t know this package.

Don’t understand what you want to do…
ctrl+double click is already used by ST:

{ "button": "button1", "count": 2, "modifiers": "ctrl"], "press_command": "drag_select", "press_args": {"by": "words", "additive": true} },
As mousemap doesn’t support context (shame, so almost useless for me), you can only redefined existing mousemap.
So your command is triggered instead of the default one.

IMHO, you better try to use an unused mousemap and not try to use an existing one.

0 Likes