Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #12273 > unrolled thread

Quirks of EventHandler

Started byp.ramsden@imperial.ac.uk
First post2012-11-08 07:10 +0000
Last post2012-11-08 07:10 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Quirks of EventHandler p.ramsden@imperial.ac.uk - 2012-11-08 07:10 +0000

#12273 — Quirks of EventHandler

Fromp.ramsden@imperial.ac.uk
Date2012-11-08 07:10 +0000
SubjectQuirks of EventHandler
Message-ID<k7fls8$jit$1@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?

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web