Sublime Forum

Mouse click coordinates

#1

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.

0 Likes

#2

Further unanswered questions about drag_select: How does drag_select work?

0 Likes

#3

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]

0 Likes

#4

Nope, doesn’t exist yet.

0 Likes

#5

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!

0 Likes

#6

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_.

0 Likes