LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I identify the button that has been pressed?

Hi,

I have an application that has a single event handler which handles 8 different menu selection items (they happen to be sources for a scope display). Since handling any of these requires knowledge of all of these, it makes sense to handle all of them with a single event, rather than configure one event per button.

So, the question is, once I enter the event handler, how do I determine exactly which of the buttons (menu item, actually - sorry for the interchangeability) has been pressed? I have:

Source
Type
Time
CtlRef
OldVal
NewVal

as possible parameters, but none of these provide an identification as to which one was pressed. BTW, the reason for doing this is that if the change happens to result in an invalid configuration, I wish to reset the menu selection to the previous value.

Thanks,

Jason
0 Kudos
Message 1 of 5
(2,437 Views)
One of the data you get from the event structure when you're asking about a control is its reference (that's the CtlRef one). You can build a 1D array of references and search it for that reference and wire the index result into a case structure.

___________________
Try to take over the world!
0 Kudos
Message 2 of 5
(2,428 Views)
As an alternate to searching refs, you can a) go the long way and just build one event per button or b) put the buttons into a cluster and search for the changed value that way.

An example of 'b' is attached (LV 6.1).
0 Kudos
Message 3 of 5
(2,421 Views)
As another alternative, you can wire the CtrlRef to a proerty node and use the property Label.Text to get the name.
Message 4 of 5
(2,412 Views)
Hey, thanks - the reference is *exactly* what I needed to make this work. I even incorporated it into some other areas of the program.

Jason
0 Kudos
Message 5 of 5
(2,403 Views)