This takes a little patience to reproduce, but I got a screenshot of it in version 9 on Mac OS X 10.7.5:

With a small Graphics object, it occasionally happens that MousePosition doesn't get updated when your mouse enters the graphic from the bottom.


Graphics[{Orange, Rectangle[{0, 0}, {1, 1}]}, ImageSize -> 60,
  PlotRange -> {{0, 1}, {0, 1}}]


As the image shows, the mouse is clearly inside the orange square, but the line above shows None instead of the mouse coordinates relative to the PlotRange. If I leave the square toward the top and re-enter from the top, the mouse position starts following my movements. To see the effect of the frozen None mouseposition, it seems I have to enter the rectangle from the bottom. I have to try this a couple of times - it doesn't happen every time.

Is there a way, perhaps by surrounding the Graphics command in some other environment, to insure that the MousePosition is recorded more reliably?


I've now reproduced it on Mathematica version 9 and 8.0.4, OS X 10.7.5 on two different computers.

Edit 2

Although I'm not 100% sure, I strongly believe that jVincent's observation is correct: to reproduce this, I have to set the zoom level of the notebook, or the Magnification setting in Advanced Preferences > Global Preferences > Notebook Options > Display Options to something other than the default 100 % (or 1, respectively). In my case, the latter was set to 1.25 when I made the screen shot.

  • $\begingroup$ Can't repro (fortunately). Mma 8.0 on WinXP $\endgroup$ – Dr. belisarius Jan 21 '13 at 6:29
  • $\begingroup$ Can't reproduce in version 9 on win7 64-bit. $\endgroup$ – Silvia Jan 21 '13 at 7:38
  • $\begingroup$ @Silvia So either it's Mac specific, or worse: hardware specific. I'm on a new Macbook Pro with retina display and NVidia Graphics card. $\endgroup$ – Jens Jan 21 '13 at 7:49
  • $\begingroup$ I can't reproduce either. Tried for a long time. Mac Book Pro, OS 10.8.2, AMD Radeon HD 6750M 1024 MB, Mathematica V9. $\endgroup$ – Matariki Jan 21 '13 at 8:04
  • $\begingroup$ Hmm.. It's an NVidia here too (9800GTX). Hope it's not that bad.. $\endgroup$ – Silvia Jan 21 '13 at 8:11

Since this issue has been confirmed on several different operating systems and in Mathematica versions 8 and 9, it seems that it should be reported as a bug. I've done that [TS 2418].

In the meantime, one possible way to avoid the glitch is this:



 Graphics[{Orange, Rectangle[{0, 0}, {1, 1}]}, ImageSize -> 60, 
  PlotRange -> {{0, 1}, {0, 1}}],
 "MouseMoved" :> (p = MousePosition["Graphics"])]


{0.7, 0.02}


The mouse in this snapshot was over the box (not captured in the shot), but its position again was not recorded by the first Dynamic[MousePosition["Graphics"]].

However, the second output ({0.7, 0.02}) is the correct result. It is generated by p = MousePosition["Graphics"] as the handler for the "MouseMoved" event over the Graphics expression. Fortunately this event is triggered reliably, even when the first MousePosition doesn't get updated. So the assignment to p as a response to entering the graphic forces the update with the correct mouse coordinates.


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.