LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Key Up

Hi ...
 
I wanted to do a calculation of a value as soon as the user entered some value. I thought I could simply use the Key Up Event in my event structure, but this doesn't seem to work. Could anyone please tell me what I'm doing wrong?
 
I attached an example. Explanation: Whenever some key is pressed, the new value of the whole text should be taken to the new field. Thank you for help 🙂
0 Kudos
Message 1 of 12
(3,137 Views)
Hello,

I think that you have a problem of refresh. The Numeric control only is read when the program starts. So your Indicator never update to the new value.

See the attached picture to clear you out.


Software developer
www.mcm-electronics.com





PORTUGAL
0 Kudos
Message 2 of 12
(3,130 Views)

Hi Jorge

 

I tried your example but the effect is still the same ... It acts upen the first keypress (and does what it's supposed to) but ignores everay further keystroke ... Could it be that the problem occurs because I'm using References instead of local variables?

0 Kudos
Message 3 of 12
(3,123 Views)
The problem is that the ACTUAL value of the control only changes when the control loses focus.  If you type into the control, it will always update to the last valid value, and the new value is only implemented after the control you are typing in loses focus.  Type once, and press enter.  You have the "old" value.

Do it again, and you will always be presented with the "old" value, i.e. Iteration minus 1.

I'm not aware how you can force this to work how you want, but maybe someone has an idea...

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 4 of 12
(3,121 Views)

You need to do a couple thing.

First, you need to move the control that you reading inside the loop and event case. The controls value will only be read when it gets scanned during program execution. With the control outside the loop, its value only gets read once before the loop starts.

Since the value of the control doesn't actually change until the control loses focus, you need to force the focus away from the control before it is read. You can do this with a property node.

Attached is a modified version that I think does what you want.

Ed



Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 5 of 12
(3,115 Views)
Thank you. I didn't know the focus issue, looks like this is the point.
0 Kudos
Message 6 of 12
(3,111 Views)
Hi Ed
 
Thank you for your response. Unfortunately your VI will really put away the focus, so the user cannot enter 2 numbers after each other without having to click. I will try to evaluate which version to use, either updating when the value gehts updated or use your version.
 
Thank you for your response 🙂
0 Kudos
Message 7 of 12
(3,111 Views)
"Unfortunately your VI will really put away the focus"

So re-set the focus.  You can also set the selection range of the text representation so that the user doesn't even notice the change......

Shane.

PS Nice one Ed.

Message Edited by shoneill on 02-22-2007 02:48 PM

Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 8 of 12
(3,098 Views)
Give this a try.
 
It looks at how many numbers are in the control and sets the cursor to the end of the number after you type in a new number.
 
Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 9 of 12
(3,096 Views)
Looks like we cross-posted.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 10 of 12
(3,089 Views)