LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Button respond to Enter key

Solved!
Go to solution

I have a Save button on the front panel. I want to have it respond to Enter key on the key board. No matter what else control is selected, if use presses Enter key, I want this Save button to be clicked. Is it possible? Thanks to anyone who can provide advices.

 

Guangde Wang

Message 1 of 15
(15,670 Views)
Right-click on the Save button and press 'Properties'. Navigate to the 'Key Navigation tab and in Toggle select Return.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
Message 2 of 15
(15,668 Views)

Hi Adnan,

 

Thank you for responding to my question. I tried it  and it worked as you described. But the behavior is different from clicking the Enter key. I think by clicking the Enter key, we enter the value first if we just finished typing a value into a control.  But by using the enter key, it's like the value is not entered, so the control is empty.

 

Guangde

0 Kudos
Message 3 of 15
(15,664 Views)
Is it possible for you to post a VI so I can understand the problem. I am not sure I understand when you say 'clicking the Enter key'.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 4 of 15
(15,655 Views)

Adnan Z wrote:
Right-click on the Save button and press 'Properties'. Navigate to the 'Key Navigation tab and in Toggle select Return.

 

Apart from this, you need to select the option "Skip this control while tabbing" in the same dialog. Smiley Wink

 

Else, the user can always select the other control(s) to get highlighted using the Tab key. Smiley Happy

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 5 of 15
(15,633 Views)

Thank you for responding to my question.

 

What I wanted is like some of the web log in pages. We enter username, password, then we click Login button. We can also press Enter key right after finishing typing in password. We don't have to move the focus away from the password textbox, pressing Enter key is equivelant to using mouse to click Login button. In the process, it's like we entered the password in the password textbox first, then clicked the Login button. The behavior of the vi I tried is like we didn't enter the password, the typed password is abandoned after the Enter key is pressed.

 

Guangde

0 Kudos
Message 6 of 15
(15,614 Views)
If you are doing a simple login screen, make sure that the username and password text boxes have "Update value while typing" option turned on. I belive that LabView normally doesn't poll the control until focus is lost on that text box.
0 Kudos
Message 7 of 15
(15,613 Views)
Right click the string controls and select "Update Value While Typing".  This way when the user presses the enter key, the new key value has already been entered, they won't need to click away for the changes to take effect.
0 Kudos
Message 8 of 15
(15,608 Views)

This is a common issue and relates to the order in which events occur when you hit a key that triggers a button event.  Depending on how your code is set up you may be able to fix this by checking off the "Set to focus on toggle" checkbox in the Key Navigation properties, but if that doesn't fix it in your case then you'll need to change your code to re-read the value of the string control AFTER the boolean event occurs (for example, put the string control's terminal is inside the event structure, in the case that handles the boolean value change).

 

Here's what happens: the value of the string control does not change until the string loses focus.   When you hit the enter key it triggers the boolean value change event, but doesn't cause the string to lose focus, so the string control still contains its old value.  By forcing the enter key to give focus to the boolean at the same time, you cause the string control's value to update.  However, if for some reason you're also handling a value change event in the string control, be aware that the string's value change event will occur after the boolean's value change.

0 Kudos
Message 9 of 15
(15,608 Views)
Solution
Accepted by topic author guangdew1
Here's an example.
Message 10 of 15
(15,601 Views)