LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2 Second Button Press Activation

I'm working on a touchscreen application and I have a basic control that has large buttons on it. I want to make the buttons only activate if the user has held his/her finger on the button for 2 seconds or more. I'm using  Mouse Down event structures to detect the button presses, BUT how do I make the user hold the button down for 2 seconds before the button actually activates?
 
Ideally I would love to just be able to "hold for 2 seconds" and have it trigger as opposed to "hold for 2 seconds and release" but I can't get either to work. Thanks folks and we got a weekend coming up!
 
-- Matt
0 Kudos
Message 1 of 3
(3,045 Views)
Here is a VI (LV8.20) that does what you want, mostly. It uses Mouse Down, Mouse Up, and Mouse Leave events to control a timer and to toggle a boolean indicator. Mouse Down on th ebutton starts the timer. Mouse Up or Mouse Leave before the 2 seconds causes the timer to stop. If the mouse stays down on the button for more than two seconds, the indicator state toggles.

If you are using other events, this likely will not work properly in all cases. A better approach might be to put the timer into a parallel loop (rather than the timeout case) and just send messages via a queue about which events have occurred.

Lynn
Message 2 of 3
(3,030 Views)

Thanks Lynn! I should call you "Circuit City" because that is "just what I needed"!

 

-- Matt

 

0 Kudos
Message 3 of 3
(2,997 Views)