LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Buttons that remain pressed

Solved!
Go to solution

Hello,

 

I have noticed that in a VIs with buttons, when a button control is selected using the TAB key and the value of the button is set to True by pressing the Enter key, the button remains True.

Until recently, these buttons were only operated by the mouse and therefore had not been noticed.

 

 

Here is a simplified VI that can reproduce that problem.

 

buttonsRemainPressed.png

 


The mechanical action of the button is 'switch until released', but when the button is turned on by pressing the Enter key, it does not return to the OFF state.

 

 

This simplified example can be dealt with by programming those buttons to switch off when that VI is opened, but the VIs I actually want to use cannot be solved in such a way, as pressing the button does not close that VI.

 

Is it possible to get the behaviour of the keyboard operation correct, or to prevent the keyboard operation from selecting a button, or to prohibit the Enter key from setting the value of a button to True?

 

Thank you for your interest.

0 Kudos
Message 1 of 11
(1,221 Views)
Solution
Accepted by topic author n_kusumoto

Changes made:

1. Changed the Mechanical Action to Latch When Released.

2. Edited the event for button1 to Value Change.

-------------------------------------------------------
Control Lead | Intelline Inc
Message 2 of 11
(1,175 Views)
Solution
Accepted by topic author n_kusumoto

@n_kusumoto wrote:

Hello,

 

I have noticed that in a VIs with buttons, when a button control is selected using the TAB key and the value of the button is set to True by pressing the Enter key, the button remains True.

Until recently, these buttons were only operated by the mouse and therefore had not been noticed.

 

 

Here is a simplified VI that can reproduce that problem.

 

buttonsRemainPressed.png

 


The mechanical action of the button is 'switch until released', but when the button is turned on by pressing the Enter key, it does not return to the OFF state.

 

 

This simplified example can be dealt with by programming those buttons to switch off when that VI is opened, but the VIs I actually want to use cannot be solved in such a way, as pressing the button does not close that VI.

 

Is it possible to get the behaviour of the keyboard operation correct, or to prevent the keyboard operation from selecting a button, or to prohibit the Enter key from setting the value of a button to True?

 

Thank you for your interest.


Skip the control while tabbing. That option is designed for just this problem. 

 

As you just discovered, when you obtain focus and press Enter the value the sw until released MA control will toggle the state and hold it until key focus? Is false.  This is  not a good programming choice!  Don't do that again.


"Should be" isn't "Is" -Jay
Message 3 of 11
(1,144 Views)

Hi JpB,

 

By your advice, I have learned that there is an option to 'Skip the control while tabbing'. Thank you!

Using that option would be the quickest way around the problem.

 

However, a question arises in my mind.
If selecting buttons by tabs always causes problems, and if buttons should not be selected by tabs, why are buttons selectable by tabs in the first place?

 

Isn't there a way to deal with this problem properly?

0 Kudos
Message 4 of 11
(1,136 Views)

They don’t always cause trouble but don’t work nicely for the latch when released option, do a tab after “pressing” the button and the lost key focus would commit the button press.

Rolf Kalbermatter
My Blog
Message 5 of 11
(1,133 Views)

Hi ZYong, 

 

Thank you very much.

 

By following your advice, I have confirmed that this problem is controlled in my project.

 

From the information provided by rolfk, I cannot be sure that I have avoided all the problems caused by selecting with the Tab key in this project, so I have decided to take the solution of making selection with the Tab key impossible in this case.

 

I will make use of your advice when I have a better understanding of Labview.

Message 6 of 11
(1,112 Views)

@JÞB wrote:

@n_kusumoto wrote:

Hello,

 

I have noticed that in a VIs with buttons, when a button control is selected using the TAB key and the value of the button is set to True by pressing the Enter key, the button remains True.

Until recently, these buttons were only operated by the mouse and therefore had not been noticed.

 

 

Here is a simplified VI that can reproduce that problem.

 

buttonsRemainPressed.png

 


The mechanical action of the button is 'switch until released', but when the button is turned on by pressing the Enter key, it does not return to the OFF state.

 

 

This simplified example can be dealt with by programming those buttons to switch off when that VI is opened, but the VIs I actually want to use cannot be solved in such a way, as pressing the button does not close that VI.

 

Is it possible to get the behaviour of the keyboard operation correct, or to prevent the keyboard operation from selecting a button, or to prohibit the Enter key from setting the value of a button to True?

 

Thank you for your interest.


Skip the control while tabbing. That option is designed for just this problem. 

 

As you just discovered, when you obtain focus and press Enter the value the sw until released MA control will toggle the state and hold it until key focus? Is false.  This is  not a good programming choice!  Don't do that again.


Then again, there is a front panel option to highlight the Enter Boolean.  Indeed, many (most?) dialog boxes have a button highlighted.  I don't think they are being highlighted so you can go click on them with your mouse.

 

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 11
(1,006 Views)

Hi Bill,

 

The color of the buttons in this image were normal until they were 'pressed' by the Tab and Enter keys.


Not only did they change color on display, but their value also remained 'true', and once they were in such a state, running that VI would immediately stop it.

0 Kudos
Message 8 of 11
(993 Views)

@n_kusumoto wrote:

Hi Bill,

 

The color of the buttons in this image were normal until they were 'pressed' by the Tab and Enter keys.


Not only did they change color on display, but their value also remained 'true', and once they were in such a state, running that VI would immediately stop it.


Yes, I understand what the original problem was, but I was commenting on the fact that highlighting a default button is at least a somewhat accepted practice.  But now that you made me look at my post again, I realize that what @JÞB was talking about was not using that particular combination of mechanical switch type and key press.

 

My effectiveness as a contributing member of this forum appears to be on the wane; I think maybe it's time for me to go "read only" on this forum.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 11
(984 Views)
Your continued active posting is still valuable and valued. I can't tell you how many times I have had posts bashed by myself and others.

You learn more by active participation and even the mistakes corrected by other posters are EXTREMELY helpful to the next readers who learn the same thing.

Over time, some common issues just don't even show up anymore because they have been so thoughtfully discussed. I.e. my little pice of code called Time to XL.vi hasn't been linked to in a few years. Yet it was once the single vi with the most accepted solutions. And a healthy P-C Loop vs QMH debate hasn't been seen in a long time. Group knowledge just keeps spreading.

"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 11
(976 Views)