4
$\begingroup$

It seems that this issue has been raised a few times, but what exactly does MousePosition["Graphics"] answer?

This code

Dynamic @ p
 Graphics[
 EventHandler[
  Disk[], {"MouseMoved" :> (p = MousePosition["Graphics"])}]]

nicely displays mouse position in the "current graphics" coordinate.

But try to put the graphics in another Graphics (GraphicsColumn in this case):

Dynamic @ p
GraphicsColumn @ 
 List @ Graphics[
   EventHandler[
    Disk[], {"MouseMoved" :> (p = MousePosition["Graphics"])}]]

The coordinates now seem to be in the coordinate system defined by GraphicsColumn.

I will greatly appreciate any answer with a workaround (even not so generic solution).

P.S. Interesting enough GraphicsColumn breaks LocatorPane behaviour. LocatorPane manages to get correct coordinates (it uses custom LocatorPaneBox) but locators do not display:

pts = {};
GraphicsColumn @ 
 List @ LocatorPane[Dynamic[pts], Graphics[Circle[]], 
   LocatorAutoCreate -> All]
Dynamic[pts]
$\endgroup$
2
$\begingroup$

In the example above

MousePosition["Graphics"] should be changed to MousePosition[{"Graphics", Graphics}] to limit the coordinate system to the innermost expression with head Graphics.

Unfortunately this does not work either.

After the discussion with the developers this was reported to WRI.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.