LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW String Control: Can you move the "typing cursor" programmatically? [Or fire a key on the keyboard programmatically?]

[NOTE: The "typing cursor" is not to be confused with the Waveform Graph "Cursor" List.]

I am working on a VI that watches what my end-users are typing into a String Control [via the "UpdtWhileTyping" property of the String Control] and corrects [on the fly] for some standard data-entry errors that we see.

Most of the time, the corrected strings are shorter than what the user had typed, and the "typing cursor" remains at the end of the string, as it should.

On very rare occasions, however, the corrected string is longer than what the user had typed, and in that case, I get bad behavior: The LabVIEW string control insists on keeping the "typing cursor" at what had been the end of the shorter string typed by the user.

I have attached a simple VI, "Append 9.vi", which illustrates the problem - when a user types any key, the VI appends the character "9" to the end of the string.

Now if the user were to type "a" followed by "b" followed by "c", I'd like them to see the following [where "|" indicates the typing cursor]:

a9|
a9b9|
a9b9c9|

Instead, they see the following:

a|9
ab|99
abc|999

Is there any way to move the "typing cursor" programmatically, so that I can get it back to the end of the string? Alternatively, is there any way to fire a keyboard key programmatically, so that I could e.g. fire the "End" key, and move the cursor to the end of the string?

Thanks!
0 Kudos
Message 1 of 3
(4,150 Views)
Just use the Text>Selection>Start property node (3 lines above the "Limit single line"), with a large input value.

CC
Chilly Charly    (aka CC)
Message 2 of 3
(4,149 Views)
Awesome, dude!

I had tried "Text > Selection > End", thinking that I needed to move the cursor to the "end" of the string, but it hadn't dawned on me that I needed to look at the "end" of the existing string as though it were the "Start" of a new string.

I've attached an "Append 9 UPDATED.vi" that shows the correct behavior.

Thanks again!
Message 3 of 3
(4,135 Views)