MathGroup Archive 2012

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

Search the Archive

Re: Quirks of EventHandler

  • To: mathgroup at
  • Subject: [mg128612] Re: Quirks of EventHandler
  • From: "Ramsden, Philip J" <p.ramsden at>
  • Date: Thu, 8 Nov 2012 19:03:31 -0500 (EST)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • References: <>

Hi John.

Yeah, sorry to have been unclear; let me explain at more length.

I'm implementing in CDF something I've already done in Java. I've realised the "knottiness" arises not because all the events are invoked as described (as you say, this is the case in Java as well), but because in a lower-level interface like Java you listen for a MouseEvent and then call a getID() on it, which makes it easy to set up, in one place in the code, arbitrary if-then-else type structures based on (a) what comes out of getID() and (b) the values of various boolean fields.

Now, because that's not how EventHandler works, I've needed to unpick the logic a bit and stitch it back together in a functionally equivalent way. But in the end, it wasn't that hard, and I was a bit premature earlier. Pretty much working now.


-----Original Message-----
From: John Fultz [mailto:jfultz at]
Sent: 08 November 2012 14:34
To: Ramsden, Philip J
Cc: mathgroup at
Subject: [mg128612] Re: Quirks of EventHandler

In most user interfaces (okay, most is every single interface I have ever tried), a super-long-depressed click is still a click.  E.g., if you press and hold a button, then have a long cup of coffee in your other hand, then let go of the clicked the button.  And, important point here, that button wasn't clicked until you *let go* of the mouse.  There's just no way at all that one can know when the mouse goes down what the user will do; Mathematica is not [yet] capable of predicting the future.

You seem to suggest that "regularizing" this would involve determining which of MouseDown/MouseUp and MouseClicked should be passed, but I just don't see how one can do that.  You want the MouseDown event immediately, not after some pregnant pause to try to suss out the user's intent.  And if we're giving you the MouseDown event, why would you sometimes not want to see the MouseUp event?

John Fultz
jfultz at
User Interface Group
Wolfram Research, Inc.

On Nov 8, 2012, at 1:09 AM, p.ramsden at wrote:

> 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?

  • Prev by Date: Re: Quirks of EventHandler
  • Next by Date: Re: Non Commutative Multiply
  • Previous by thread: Re: Quirks of EventHandler
  • Next by thread: Re: Quirks of EventHandler