MathGroup Archive 2009

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

Search the Archive

Re: no Condition in EventHandler?

  • To: mathgroup at
  • Subject: [mg100206] Re: [mg100064] no Condition in EventHandler?
  • From: John Fultz <jfultz at>
  • Date: Thu, 28 May 2009 04:27:56 -0400 (EDT)
  • Reply-to: jfultz at

You are correct.  You should, instead, use CurrentValue[] on the rhs of the
"MouseDown" event handler to probe the behavior.  The EventHandler will trigger 
for every "MouseDown" event, of course, but just code the event handler so that 
it's a no-op when you don't need it, and does the appropriate thing when you do.

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

On Fri, 22 May 2009 01:51:02 -0400 (EDT), Michael wrote:
> EventHandler[
> "TEST",
> ("MouseDown" :> Print[1]) /; CurrentValue["AltKey"],
> ("MouseDown" :> Print[2]) /; CurrentValue["ControlKey"],
> ("MouseDown" :> Print[3]) /; CurrentValue["ShiftKey"],
> ("MouseDown" :>
> Print[4, CurrentValue["AltKey"], CurrentValue["ControlKey"],
> CurrentValue["ShiftKey"]]) /; True,
> "MouseDown" :>
> Print[5, CurrentValue["AltKey"], CurrentValue["ControlKey"],
> CurrentValue["ShiftKey"]] /; False
> ]
> Does not do what I expect.  (5 is always printed, and nothing else, no
> matter what keys are down).
> I can only speculate that EventHandler doesn't evaluate its actions in
> such a way that a Condition has a chance to take effect or not?

  • Prev by Date: Mathematica for Behavioral Research?
  • Next by Date: Re: Correlating two lists
  • Previous by thread: Re: no Condition in EventHandler?
  • Next by thread: Animated Bubble Chart