Quirks of EventHandler
- To: mathgroup at smc.vnet.net
- Subject: [mg128595] Quirks of EventHandler
- From: p.ramsden at imperial.ac.uk
- Date: Thu, 8 Nov 2012 02:09:46 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
I recently saw the following query from Hugh Goyder in the archive (excerpt follows): I am trying to work out how to get separate events from MouseDown, MouseDragged, MouseUp and MouseClicked. As far as I can see if the mouse is clicked this is also an event for MouseDown and MouseUp. Similarly however long I wait between a down and an up I get a click. How are you meant to separate out events if you are mixing downs, ups and clicks? I've been wrestling with this as well, and Hugh is right. The following example illustrates what's going on: DynamicModule[{col = Red, event = "nothing"}, EventHandler[ Graphics[{Dynamic[col], Disk[], White, Text[Dynamic[ StyleForm[ToString[event], FontSize -> 36]]]}], {"MouseClicked" :> (Pause[1]; event = "clicked"; col = Blue), "MouseDragged" :> (Pause[1]; event = "dragged"; col = Green), "MouseUp" :> (Pause[1]; event = "up"; col = Darker[Yellow]), "MouseDown" :> (Pause[1]; event = "down"; col = Black)}]] In summary, the issue seems to be that when you click the mouse, this instantiates first a MouseDown event, then a MouseUp event and only then a MouseClicked event. And as Hugh points out, even a prolonged depression of the mouse button counts as a click! I'm working on a workaround for my own application; probably knowing the order in which these events occur will help. Slightly knotty problem though, and I can't help feeling, knottier than it needs to be... Anyone know whether this behaviour will be regularised in 9?
- Follow-Ups:
- Re: Quirks of EventHandler
- From: "Ramsden, Philip J" <p.ramsden@imperial.ac.uk>
- Re: Quirks of EventHandler
- From: "Ramsden, Philip J" <p.ramsden@imperial.ac.uk>
- Re: Quirks of EventHandler
- From: John Fultz <jfultz@wolfram.com>
- Re: Quirks of EventHandler