Grids of dynamic objects responding to mouseovers seem to be quite slow in general, for instance:

  Mouseover[Framed[" ", Background -> Blue], 
   Framed[" ", Background -> White]], {i, 50}, {j, 50}], 
 Spacings -> {0, 0}]

How can this lagging be avoided?

  • $\begingroup$ It seems reasonably fast to me; how much lag are you seeing? $\endgroup$ – Mr.Wizard May 28 '12 at 8:05
  • $\begingroup$ About a second, but If you increase the size of the grid it gets worse fast. $\endgroup$ – M.R. May 28 '12 at 8:09
  • $\begingroup$ Okay, if I make the grid bigger, e.g. 150x150 I see the lag. What is your application for this many Mouseovers? Perhaps there is a faster approach. $\endgroup$ – Mr.Wizard May 28 '12 at 8:12
  • $\begingroup$ What platform as you on? Linux? On a fairly outdated Windows machine I can highlight about 6-8 cells per second. $\endgroup$ – Szabolcs May 28 '12 at 8:21
  • 1
    $\begingroup$ I had similar problems: I wanted the user to be able to click on a grid. Solved the problem by having just one click event and determining the bin from the mouse coordinates manually. $\endgroup$ – Ajasja May 28 '12 at 13:17

I think the problem is not the Mouseover itself, but with the redrawing of the Framed elements.

This, for example, is much faster:

  Mouseover[Style[" ", Background -> Blue], 
            Style[" ", Background -> White]], {i, 50}, {j, 50}], Spacings -> 2,
  Frame -> All]

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.