LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generic event handler for latched buttons

Solved!
Go to solution

Hi all,

 

In my LV8.5 application I have 15 latched buttons. By clicking a button i want to load a profile, so except the profile to load, the action for each button is the same. I made one event handler to load the profile, the value change events from all 15 buttons point to this event handler. Looking at the name suffix of each button, I select the correct profile and load it.

 

At first I didn't notice any difference between the Switch and Latch mechanical actions: when a button was clicked it held its 'clicked' visual status. I came across this post, explaining that the button returns to its initial state by reading the button's terminal. So I added all the button terminals to the event handler and make a dummy read. This resulted in resetting the buttons when clicked.

 

In my opinion this isn't a nice solution since when I want to add more buttons, I have to add them to the event handler and add the button terminals to the dummy read.

 

I tried to dummy read the 'NewVal' terminal of the event handler, but this doesn't reset the operated button.

 

I tried to read the value of the button via the 'CtlRef' terminal of the event handler. This approach resulted in an error message: Error 1193 LABVIEW: When a Boolean control has a latch mechanical action, you cannot use the Value property to read or write its value.

 

Is there a generic way to reset a latch button from the event handler?

Is there a nicer approach to implement this functionality?

 

Thanks in advance,

Stef

Download All
0 Kudos
Message 1 of 4
(2,612 Views)
Solution
Accepted by topic author svh

Yes, this can be really annoying...

 

There is a Value Latch property, but it's a brown node. That means it's subject to change over versions, and basically only for internal (NI) use...

 

An easy solution is to make all buttons "switch", and set the value back to the old value with a property node. Or not if it is a switch. So you need a mechanism that tells you if the button is switch or fake latch.

 

Or you can use Reinit to Default, but you still need to check if the button is latch or switch, because you don't want to reinit the switch Booleans. (This is probably easier).

Message 2 of 4
(2,603 Views)

You do not need to wire anything to the terminals.  They just have to be sitting in the event case.

 

Alternatives:

1. Array of Booleans.  Then you just have 1 terminal and it is fully expandable.  Use Search 1D Array to find the TRUE in the array.

2. List Box, Combo Box, Ring, or Enum.  You can just load the new profile on the value change or you can add a button to load the selected profile.

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 4
(2,576 Views)

I made the buttons mechanical action switch and reset them in the event handler. Now it works as I want, Thank you very much

 

The UI I'm making has to have all options viewable at once and selecting has to be as quick as possible. A ring or combobox requires an extra mouseclick to view all options and a boolean array can't have the text on the control itself. So I'll stick with the buttons.

0 Kudos
Message 4 of 4
(2,564 Views)