LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Update array value on key down

Solved!
Go to solution

Hello,

 

I have an array of clusters.  Contained within each cluster are two numeric controls.  One displays a value in decimal the other displays the same value in hex.  I'd like the user to be able to enter values into either the decimal or hex numeric control and have the other field update while the user is typing.

 

I can create a key down event for the array. What I don't understand is how to get from the CtlRef to knowing which cluster in the array and then which specific control has changed.

 

Any help is greatly appreciated.

 

 

0 Kudos
Message 1 of 5
(3,100 Views)
Solution
Accepted by topic author JohnSantaFe

It would be easier if you just had one control which displayed the value in two different formats, which you can do. For an I32 integer control:

  1. Right-click on the control and select "Format & Precision".
  2. In the window select the "Advanced editing mode" option button. 
  3. In the "Format string" text box replace the text with the following:
    1. %d
    2. hit Shift-Enter on your keyboard
    3. 0x%08x  (this means prepend the characters "0x" to indicate hex, and format to 8 digits, prepending unused ones with zeros)

Now the control will show two lines. The top will be decimal, the bottom will be hex. The user can enter the value whichever way they want.

 

Hmmm... Maybe Darren should turn this into a mini-nugget. 

Message Edited by smercurio_fc on 07-05-2009 08:34 PM
Download All
Message 2 of 5
(3,093 Views)

That's an excellent solution.  I was able to extend your idea and also diplay the binary representation too.

 

One follow up, I've noticed the numeric value does not get placed into the variable unless the user clicks somewhere else on the front panel before clicking on a button. For strings I solved this using the 'update while typing' option. Is there a similar option for numeric controls or is there something I can do in my button event handler to force it to read the new value?

 

Thanks!!

0 Kudos
Message 3 of 5
(3,033 Views)

I'm not sure I understand what you mean by "placed on the variable". The control's value doesn't get updated until the user presses the <Enter> key or clicks somewhere else (including a button). There is no option for a numeric control to update the value while typing. It sounds as if your button event handler is "Mouse Down". If you use "Value Change" then you can be sure that the numeric control's value will be updated before the button's event fires. See attached demonstration. 

0 Kudos
Message 4 of 5
(3,017 Views)

Ah, that was it exactly. I was using mouse down instead of value change with the event handler.

 

Many thanks!

 

0 Kudos
Message 5 of 5
(3,014 Views)