Hi Rast

the mouse event object of editor% and snip% is always the one passed to the
on-event method of editor-canvas% (that's why event handlers of snip% have
lots of extra arguments to provide you the location information,
racket/snip do the computing for you). When it is used with a snip%
instance directly, you have to check the docs to see the proper way to use
it correctly. Another thing you should take care is that, the event object
itself is not able to tell you the snip%s' enter and leave stats.

A1 & A2: You have get-top-level-windows and get-current-mouse-state. (But
the Question 1 is not necessary for your requirements here).
A3: You have get-snip-location, local-to-global, and client->screen.


On Tue, May 23, 2017 at 10:24 PM, Erich Rast <er...@snafu.de> wrote:

> Hi,
>
> For me personally, coordinates are probably the most unintuitive aspect
> of Racket's GUI management. The problem comes up again and again, and I
> never get it right, so maybe someone can clarify this once and for all.
>
> I have a mouse-event% in on-event of a snip% and would like to display
> a floating frame% just below the mouse.
>
> Question 1: What is the right way to obtain the window in a potentially
> nested hierarchy of editors? I'm currently using:
>
> (define top-window (and-let* ((canvas (get-canvas))
>                                (top (send canvas get-top-level-window)))
>                       top))
>
> is that correct?
>
> Question 2: How do I obtain the right coordinates for the frame% that I
> would like to show below the mouse?
>
> I assume it has something to do with top-window above, but how do I
> convert from the coordinates of the mouse-event to the 'right'
> coordinates? Currently, the frame% appears offset about 20 to 20 pixels
> below the top-window's top-left corner and not at all where the mouse
> is located.
>
> Are the mouse-event coordinates relative to the editor? Or relative to
> the snip within the editor? How do I convert them?
>
> Question 3: Suppose I want to do the same with a snip% displayed in a
> text% with one editor-canvas%, i.e., show a floating window just below
> the snip%. Use cases: tooltips, spell corrections, etc.
>
> How do I do that?
>
> Thanks a lot in advance!
>
> Best,
>
> Erich
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to