07-26-2012 06:11 PM
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
Solved! Go to Solution.
07-26-2012 06:16 PM - edited 07-26-2012 06:17 PM
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.
07-26-2012 06:18 PM
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.
07-26-2012 06:27 PM
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).
07-26-2012 09:36 PM
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
07-27-2012 07:42 AM
@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.
07-27-2012 09:21 AM
07-27-2012 12:08 PM
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.