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.
Solved! Go to Solution.
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.
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.