LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

How to stay in a string control box, When the vi opens

Solved!
Go to solution
Highlighted

Hi

 

I am writing a code which requires me to scan a code. But in order to do that I should click in a String Control Box and then scan, so that the alphanumeric code can appear in that box.

 

I would like to make this default. As in, I want the cursor to remain inside the String Control box as soon as I run the vi. So that I can directly scan as soon as the vi runs and the code is entered into that field.

 

Also, I have a pop-up in the middle of my code. I close the pop-up by pressing any key. After this I want the cursor to go back to the same String Control as mentioned above.

 

Please let me know what is the best way to do it.

 

Thanks

Mr. Miagi

0 Kudos
Message 1 of 3
(357 Views)

I wrote an application like this and took a different approach: I handled "Key Down" events at the VI main window level.  The user had a barcode reader that acted like a keyboard; I assume you have something similar.  There were no text controls on the front panel since the only thing the user could do was scan a barcode, which caused a corresponding label to print.  It would have been easy to add an indicator so it would look like the text was being typed/scanned in.  On each keystroke event I added that character to a string (stored in a shift register); when the final character arrived (either a tab or enter) I validated the string and then processed it.  There was also a timeout so that if too much time passed between characters, the string would be cleared; this prevented accidental keystrokes from being treated like real input.

 

Just another idea for you as an alternate approach.

0 Kudos
Message 2 of 3
(351 Views)
Solution
Accepted by topic author Mr_Miagi
08-27-2015 04:09 PM

Set Key focus property of the string control to true using its property node when you want to set the cursor back to string control.

 

keyfocus.png

0 Kudos
Message 3 of 3
(341 Views)