06-11-2012 03:57 PM
Hi all,
I was wondering if there was a way to combine user events with an AND operator to make one event. For example, I would like an event to happen when button1 AND button2 AND button3 have been pressed. Mabye event strucures arent the right way to do this, but right now when I add multiple events to one event frame, it seems to happen when any one of the events gets triggered, like event1 OR event2 OR event3 and I cant figure out how to change that.
Hopefully this makes sense what I want to do. I would nest my event structures, but I'm pretty sure that is bad and would give unexpected errors. Please advise.
Thanks!
Solved! Go to Solution.
06-11-2012 04:01 PM
Use a shift register and maintain the states of which buttons have been pressed. Then you can actually execute whatever code you want once all of them have been pressed. If you do this you may need some type of timeout to clear the buttons to the unpressed state if only one or two have been pressed and nothing more some period of time.
06-11-2012 04:02 PM
You cannot change all the buttons at once, but you can still use the OR nature of the event structure with multiple events for one case.
Create a case for the three buttons' Value Changed events. Inside the case read all three buttons. AND the result. Wire the AND to a case structure. In the True case activate the code you want for all the buttons. In the False case do nothing.
Lynn
06-11-2012 04:06 PM
@johnsold wrote:
You cannot change all the buttons at once, but you can still use the OR nature of the event structure with multiple events for one case.
Create a case for the three buttons' Value Changed events. Inside the case read all three buttons. AND the result. Wire the AND to a case structure. In the True case activate the code you want for all the buttons. In the False case do nothing.
Lynn
You will need to pay attention to the mechanal action of the buttons. If they clear when read this will not work.
06-11-2012 04:35 PM
I assumed that if the requirement is for all buttons to be pressed that meant simultaneously on which would preclude latched action. Of course the original post was not completely clear.
Lynn
06-12-2012 04:02 PM - edited 06-12-2012 04:04 PM
Mark,
Ahh yes that shift register works well. Thank you.
John,
Thanks also, but my buttons werent latched actually (so yours would have worked :P), and yes I could have been more clear in my initial description.