08-13-2023 08:33 AM - edited 08-13-2023 09:22 AM
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.
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.
Solved! Go to Solution.
08-13-2023 12:40 PM
Changes made:
1. Changed the Mechanical Action to Latch When Released.
2. Edited the event for button1 to Value Change.
08-13-2023 08:54 PM - edited 08-13-2023 09:34 PM
@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.
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.
08-14-2023 01:06 AM
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?
08-14-2023 01:11 AM
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.
08-14-2023 03:51 AM
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.
08-15-2023 05:35 PM
@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.
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.
08-15-2023 06:53 PM
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.
08-15-2023 07:31 PM
@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.
08-15-2023 11:23 PM