Is calling drag_select the only way to convert the mouse click coordinates to a text position? The x/y in event
appear to be in screen coordinates, and I don’t see a way to convert those to layout coordinates or a text position.
Mouse click coordinates
I’m looking for something more general. What I’m looking for exists in emacs, see below, where it’ll give you a way of figuring out what exactly the mouse cursor is hovering over (after transforming the resulting “frame” [ie window] coordinates to “buffer” and “buffer position” and then peeking there).
That doesn’t exist in sublime yet I gather?
[code]
mouse-position is a built-in function in `C source code’.
(mouse-position)
Return a list (FRAME X . Y) giving the current mouse frame and position.
The position is given in character cells, where (0, 0) is the
upper-left corner of the frame, X is the horizontal offset, and Y is
the vertical offset.[/code]
Adzenith, thx for quick reply!! FWIIW, I added a feature request to the user echo site:
http://sublimetext.userecho.com/topic/139558-api-pls-add-mouse-position-function/
So you can vote for it!
This function would help designing new selection methods, pop-up tips or info, and ways of using the mouse for direct text manipulation!
So, an API (view.window_to_text) has been added for this a few builds ago, but I didn’t actually use it myself yet. It’s used in Default/open_context_urls.py fo reference, along with implementing the want_event method to make ST not remove the event parameters in run_.