LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can labview update the string control (text-edit box) after we have pressed the carriage return key on the keyboard during text-editing within that box?

Dear readers,

I have been trying to work out how to get labview to detect the event when a 'string' control has been modified, where the user has finished editing the string either by 1) pressing the enter key on the keyboard, or by 2) taking the focus away from the string control again. For example.. if I use the mouse to click on the string control and then I type 1234 into the box, I would like to have a routine that does something once the user hits the Enter key of the keyboard, or when the user takes the focus away from the string control again by clicking on something else. I would like the routine to respond even when the user didn't change anything in the text box (such as when we mouse-click on the edit box to go into edit mode, and then mouse-click on something else to remove the focus with no changes to the contents in edit-box).

The purpose of my routine is to have a edit-box for a user to change for example the centre-frequency of a vector network analyser, so that the centre-frequency of the network analyser can change once the user finishes entering a new value in the text-edit box by hitting Enter key after the number is keyed in. Even if the user has clicked on the edit box, but changes their mind by mouse-clicking on something else to remove focus from the edit box, I would still like labview to detect the event when the control loses focus, so that the centre frequency can be updated anyway (to the same value that was already in the edit box).


So far, I've tried set the string control option to 'limit to single line', so that I can try to scan for a carriage return .. '\n' ... pattern in the string. Unfortunately this doesn't work because labview doesn't seem to attach the '\n' to the end of that single line.

Could someone please suggest ways to set a flag when a user hits Enter during text-edit mode of a string control, or when focus has been removed from the string control?

While I've only described my problem for controlling a single control parameter on the gpib device, I'd like to make this feature work so that I can do the same kind of thing with other control parameters as well.

Thanks so much in advance.

Kenny
0 Kudos
Message 1 of 4
(5,016 Views)
Hi Kenny,
instead of using the event structure, you can directly achieve to what you want by the KeyFocus property of the string control.
- Enable Limit to single line option
- Create the property KeyFocus in read mode and connect an indicator

Each time you click on the string to modify it KeyFocus is True; when you click away or hit Enter KeyFocus is False.
You can toggle your settings when KeyFocus changes from True to False.
Alberto
Message 2 of 4
(5,018 Views)
Thanks very much Alberto. The KeyFocus worked very well. Much appreciated.
0 Kudos
Message 3 of 4
(5,016 Views)
Hello Alberto,
 
I have trouble to edit an exited text file and save it after the content changed. Can you please help me out?
 
Thanks,
Jason 
0 Kudos
Message 4 of 4
(4,812 Views)