LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Possible to "read" a control value that hasn't been committed?

Solved!
Go to solution
In short, I would like to specifically bypass LabVIEW's convention that a value is only committed when the user moves focus away, hits the enter key, clicks on an increment button, etc. My specific scenario is that I want to respond to Key Up/Key Down/whatever events for a given control and grab the value so I can update the GUI in real-time as numbers are entered. I had thought to use the "Selected" property of the FocusObj reference to remove focus momentarily to force the value to be committed, but it seems to do nothing, at least not the way I'm using it. I also tried to use this property to select something else entirely before selecting the original control, but again, nothing. I imagine that an XControl MIGHT be able to do something like this, but I'll abandon the effort before I dip my toe in those waters. TLDR: Is there any way to cheat and grab the contents of a control while the user is still typing in it?
____
Ryan R.
R&D
0 Kudos
Message 1 of 6
(3,159 Views)

You can do that with string controls by selecting Update Value while Typing. Each character entered then will generate a Value Changed event.

You could do some validation to reject non-numeric characters and then convert the string to a numeric value.

 

Lynn

0 Kudos
Message 2 of 6
(3,143 Views)

The property you want is the "Text" property instead of the Value property. For a numeric control, this is the "Numeric Text.Text" property.

Message 3 of 6
(3,130 Views)
Solution
Accepted by topic author RnDMonkey

In addition to what nathand said, he's perfectly correct.

 

If you need to catch an event in the event structure, instead of "Value change" you better handle the keydown event and take the Numeric.Text property so the Value property won't be changed yet but you'll have access to what's shown on the control.

 

If you do what johnsold said, then the value will be updated after each character, this applies only for string controls.

0 Kudos
Message 4 of 6
(3,121 Views)
Thank you, Lynn, Nathan, and Jimmy! I'll try this out in the AM and check back in here.
____
Ryan R.
R&D
0 Kudos
Message 5 of 6
(3,098 Views)

This worked out very well! I put the following code into a KeyUp event case that I'd dynamically registered with the references to all the controls I need to watch:

Spoiler
update numeric value while typing.png

It works very elegantly in practice. Thank you again!

____
Ryan R.
R&D
0 Kudos
Message 6 of 6
(3,054 Views)