Re: no Condition in EventHandler?
- To: mathgroup at smc.vnet.net
- Subject: [mg100070] Re: [mg100064] no Condition in EventHandler?
- From: Leonid Shifrin <lshifr at gmail.com>
- Date: Fri, 22 May 2009 18:50:41 -0400 (EDT)
- References: <200905220551.BAA19281@smc.vnet.net>
Hi Michael, My guess (I may be wrong here) is that the rule semantics in EventHandler is indeed just a convenient syntax (namely, that delayed rule is used only as a convenient container which has a nice representation/formatting and does not evaluate its second arg, but no rule substitution with this rule is happening, and thus no condition is checked ). There is only one "MouseDown" event. But you may get the functionality you need in a different way - for example, like this (I changed printing to assignments to a variable displayed with Dynamic): Column[{Dynamic[x], EventHandler["TEST", {"MouseDown" :> ("anything" /. {_ /; CurrentValue["AltKey"] :> ( x = 1), _ /; CurrentValue["ControlKey"] :> (x = 2), _ /; CurrentValue["ShiftKey"] :> (x = 3)})}]}, Frame -> All] Hope this helps. Regards, Leonid On Thu, May 21, 2009 at 10:51 PM, Michael <michael2718 at gmail.com> 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? > >
- References:
- no Condition in EventHandler?
- From: Michael <michael2718@gmail.com>
- no Condition in EventHandler?