NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
schieb2
Posts: 14
0 Kudos
Accepted Solution

Boolean button that requires a double click

Is it possible to make a boolean true/false button to require two mouse clicks to switch. We wish this feature to avoid accidentally clicking a button that opens or closes a valve?

 

Thank you, Bill

Trusted Enthusiast
nathand
Posts: 2,830

Re: Boolean button that requires a double click

[ Edited ]

It can be done if you capture the "mouse down?" filter event on the boolean, and track the time between two successive events.  On the first one, discard the event, and store the time.  On the second one, if the time is within some "double-click" time, don't discard the event, which will allow the boolean to switch.

 

Can I suggest as a simpler alternative that you use a pull-down (I'm thinking an enumeration or a picture ring)?  That also requires more than a passing mouse click to change the value, and is both easier to code and more intuitive.

Active Participant
Nickerbocker
Posts: 734

Re: Boolean button that requires a double click

Hi Bill -

 

I have to program similar functionality into my apps so that when buttons are pressed they are pressed "with intent" and not accidental.  Instead of a double-click, might I suggest an "unlock" key?  I have my users press and hold the CTRL key if they want to click something in the interface that does something that you don't want to do accidently (like open a valve).  You can use an event to detect when a key is pressed down and check to see if it is the CTRL key (or whatever key you like), and then Enable the controls.  Similarly when the key comes back up the controls are disabled again.

 

 

Trusted Enthusiast
nathand
Posts: 2,830
0 Kudos

Re: Boolean button that requires a double click

Nickerbocker - just curious, when you do this, do you visually show that the controls are enabled and disabled?  Otherwise it would seem a lot easier to me to check whether any modifier keys are pressed at the time of the mouse down event (or, with a filter event, discard if the modifier key isn't pressed).

Active Participant
apok
Posts: 598

Re: Boolean button that requires a double click

[ Edited ]

add a dialog to it....VALVE.png

Member
schieb2
Posts: 14
0 Kudos

Re: Boolean button that requires a double click

Thank you. I will give this solution a try using space bar + mouse click.

Trusted Enthusiast
ian_fung
Posts: 2,597
0 Kudos

Re: Boolean button that requires a double click

Hi,

 

Attached is sort of "timed button" that was created for another member some years ago (can't remember when was it though)...

 

It might be just another possible solution to your problem. So, I am adding it to the list :smileywink:

Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010

LVVILIB.blogspot.com
Trusted Enthusiast
Norbert_B
Posts: 3,564

Re: Boolean button that requires a double click

@Ian: While i find the general idea very interesting, i don't like that timing is encapsulated only in the subVI. While it doesn't hog the CPU (which is good), it might give wrong impressions to new developers (no obvious wait funktion in the loop).

 

@OP: If it was only a double click you want to check, you might do something like in the attachment.

 

Norbert 

Trusted Enthusiast
ian_fung
Posts: 2,597
0 Kudos

Re: Boolean button that requires a double click

Dear Norbert

Thanks for the feedback. Fyi, it wasn't my idea but it was created based on the requirement of the member who needed such function.
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010

LVVILIB.blogspot.com
Trusted Enthusiast
SteveChandler
Posts: 2,249
0 Kudos

Re: Boolean button that requires a double click

Norbert, neat trick! I had never thought of a use for a disabled control that is not also greyed out. I never tried it but I am surprised that a disabled control still generates mouse events.

=====================
LabVIEW 2012


By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page