MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Simulating a Mouseover event in EventHandler

  • To: mathgroup at smc.vnet.net
  • Subject: [mg91229] Simulating a Mouseover event in EventHandler
  • From: chandler.seth at gmail.com
  • Date: Sun, 10 Aug 2008 01:53:30 -0400 (EDT)

I would like to create an interface so that when the mouse moves
within certain graphics primitives within a Graphics object various
global variables are set that, among other things, alter both the
object itself and, potentially, other directives or graphics
primitives within the object. I would have thought that EventHandler
would have an event such as "Mouseover" or "MouseIn" or "MouseOut"
that handled this sort of thing. But, so far as I can see, it does
not.

Here is the best code I've been able to come up to address this idea.
But it just looks really ugly and wrong. Anyone have ideas?

(mouseisover = False; {Dynamic[mouseisover],
  Graphics[{Dynamic[{If[mouseisover, Red, Green], Disk[{3, 3}, 1/2]}],
     Dynamic@
     If[mouseisover, {Black, Line[{{1, 1}, {2, 2}}]}, {Black,
       Circle[{1, 2}, 1/2]}],
    Dynamic@EventHandler[{If[
        MousePosition["EventHandlerScaled", False] /. {x_, y_} :>
          True, (mouseisover = True; Yellow), (mouseisover = False;
         Blue)], Disk[{0, 0}, 1]}, {(* no events are defined,
       which makes me think that the event handler construct is \
unnecessary *)}]}, Frame -> True]})

P.S. The Mouseover command does not appear to accomplish what I need
because, even with compound expressions as the arguments and Dynamic,
I cannot get it to alter global variables. But maybe I am missing
something.




  • Prev by Date: Re: Help with StyleSheets
  • Next by Date: Re: Running Notebooks inside a notebook:
  • Previous by thread: Re: Finding only final values in NDSolve
  • Next by thread: Re: Simulating a Mouseover event in EventHandler