Home Download Buy Blog Forum Support

Mouse click coordinates

Mouse click coordinates

Postby sapphirehamster on Wed Jul 25, 2012 11:13 pm

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.
sapphirehamster
 
Posts: 95
Joined: Sun Jul 01, 2012 11:19 pm

Re: Mouse click coordinates

Postby adzenith on Wed Jul 25, 2012 11:16 pm

Further unanswered questions about drag_select: viewtopic.php?f=3&t=7743&p=32659
adzenith
 
Posts: 1356
Joined: Mon Oct 19, 2009 9:12 pm

Re: Mouse click coordinates

Postby emacs_enough on Fri Nov 30, 2012 12:57 am

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: Select all
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.
emacs_enough
 
Posts: 2
Joined: Fri Nov 30, 2012 12:50 am

Re: Mouse click coordinates

Postby adzenith on Fri Nov 30, 2012 4:17 am

Nope, doesn't exist yet.
adzenith
 
Posts: 1356
Joined: Mon Oct 19, 2009 9:12 pm

Re: Mouse click coordinates

Postby emacs_enough on Fri Nov 30, 2012 7:44 pm

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!
emacs_enough
 
Posts: 2
Joined: Fri Nov 30, 2012 12:50 am

Re: Mouse click coordinates

Postby FichteFoll on Sat Mar 07, 2015 4:57 pm

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_.
FichteFoll
 
Posts: 620
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany


Return to Plugin Development

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests