Sublime Forum

How does drag_select work?

#1

If I click, drag_select gets called only once. If I click and hold, then move the mouse around to select a bunch of text, drag_select still only gets called once, yet it somehow continues to work—modifying my selection as I drag—after it returns. Does drag_select itself just start some handler that reads the mouse state directly? Is there any way I can check the state of the mouse myself, or otherwise capture mouse-down and mouse-up?
Additionally, drag_select translates screen x and screen y into a text_point. Is this functionality exposed through the API?
Thanks!

0 Likes

Mouse click coordinates
Unable to parse command: drag_select
#2

drag_select makes use of functionality that only exists on the C++ side of things, namely the ability to capture mouse events over time, and the ability to talk in window coordinates. It’s unlikely that raw event handling will be exposed in the API.

0 Likes

#3

Got it, thanks.

Will there be an api for clicks in general in the future, even if they’re not using window coordinates? Maybe something like:
on_pre_click(view, text_point) -> return False to cancel drag_select’s functionality
on_post_click(view, text_point)

This could allow e.g. clicking on hyperlinks to open webpages, or making clickable help-docs or whatever. Or text-based dropdown menus!

0 Likes

#4

This is already sort of possible with the technique described here: Customizing ctrl+click. I would love native support as well, of course.

0 Likes