From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Grouping User Interface Events

Solved!
Go to solution

I'm working on an application that has a large number (20-30) of boolean buttons on the front panel. When any of them are pressed, it drives an event structure that sends a message to one of several actors based on which button was pressed (using the Label Text property from the event reference to determine which button was pressed). Right now, I have to manually select each of the buttons to include in the event. However, this seems pretty inefficient/error prone. Is there a way that I could group all of these buttons into a single entity that I could then select from the event structure?

0 Kudos
Message 1 of 10
(3,302 Views)

Kind of. You can put them all in a cluster. If only one of them can be pushed at a time, then you just need to look for the true value. Otherwise you will need a little more thoughtful logic to figure out which button was pressed.

 

Capture.PNG

Message 2 of 10
(3,294 Views)

You can also use dynamically registered events, then all you have to do is add another reference to the array:

 

Register array of buttons.png

Message 3 of 10
(3,289 Views)

I see 3 options:

Cluster has value change event and "controls" property to get reference of hte actually pressed button. 

You can list multiple events in the same frame. It gives reference of the activated control.

You can register events dynamically and just add reference to the new button into array.

0 Kudos
Message 4 of 10
(3,287 Views)
Solution
Accepted by topic author PatW

Ideas that were previously stated with some mods. Traverse for all booleans, then dynamically register. Have a default case that does nothing in case you want to action to occur with a boolean.

 

mcduff

snip.png

 

 

 

Message 5 of 10
(3,280 Views)

Thanks! I had a feeling there was a way to do it with user events, but hadn't used them before.

0 Kudos
Message 6 of 10
(3,276 Views)

@mcduff wrote:

Ideas that were previously stated with some mods. Traverse for all booleans, then dynamically register. Have a default case that does nothing in case you want to action to occur with a boolean.

 

mcduff

snip.png

 


Maybe I am missing something but I don't see how this is useful.  Wouldn't you would still need to group the button references in an array in order to compare the event control reference against to know which one was pressed since there is no guarantee of the order that the controls are parsed? Sorry but I'm just not getting it.  Smiley Frustrated

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 7 of 10
(3,262 Views)

In this particular use case he says he uses the label text from the button to decide what action to take, and there's a CtlRef output in the event structure that gets you a reference you can get the text from.

0 Kudos
Message 8 of 10
(3,253 Views)

The traverse VI finds all the booleans in the VI. You could do some filtering if you wanted after this step if you wanted, for example to eliminate indicators.

 

The traverse VI returns an array of references, you use this array to dynamically register for events, such as value change. When one of the value changes, use the control reference in the event structure to read the label of boolean. Use this label as a case structure to decide what to do next for a particular button.

 

What is nice about the traverse VI is you do not need to create an array of references, it finds them for you.

 

mcduff

0 Kudos
Message 9 of 10
(3,250 Views)

@Gregory wrote:

Kind of. You can put them all in a cluster. If only one of them can be pushed at a time, then you just need to look for the true value. Otherwise you will need a little more thoughtful logic to figure out which button was pressed.

 

Capture.PNG


Use the not equal comparison and compare the old and new values. The latching action here is important also.

 

mcduff

0 Kudos
Message 10 of 10
(3,245 Views)