MathGroup Archive 2012

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

Search the Archive

Re: Quirks of EventHandler

In most user interfaces (okay, most is wishy-washy=85in 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 button=85you 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: Error Code: 616
  • Next by Date: Re: Quirks of EventHandler
  • Previous by thread: Quirks of EventHandler
  • Next by thread: Re: Quirks of EventHandler