06-17-2009 06:05 PM
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
Solved! Go to Solution.
06-17-2009 06:15 PM
06-17-2009 06:43 PM
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
06-17-2009 08:17 PM
06-18-2009 04:10 AM
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.
Else, the user can always select the other control(s) to get highlighted using the Tab key.
06-18-2009 09:31 AM
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
06-18-2009 09:36 AM
06-18-2009 09:39 AM
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
06-18-2009 09:47 AM
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.
06-18-2009 09:49 AM