LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't use "Latch when released" buttons when registering their Control referencies by Reg Events node...

Solved!
Go to solution

I need to handle gui controls events by registered events. Thats why I collect all gui control references and register events for "MouseUp" and "ValueChange". Thats works fine.
However if I use button with "Latch when released", button doesn't work correctly. It keeps pressed. I know I should read its terminal inside Event structure to reset it. But I can't put its terminal inside of Event structure because my solution is based on external array of Control referencies. So I tried to use property node to read button value. However it's impossible to use Value property to read button with "Latch when released" inside Events structure.

 

Does it mean I can't use "Latch when released" buttons when registering their Control referencies by Reg Events node ???

Code example....


*** LV2018 ***
0 Kudos
Message 1 of 22
(1,911 Views)

Why can't you put the control in the event case?

 

You can still read the value from the property node, or from the New Value node on the left side of the Value Change event case.

You just don't need to anything with the control's terminal.

 

You could also use switch when released, and use a local variable to reset the button programmatically in the event case.  (Not ideal.)

 

I'm curious as to why you are using a combination of mouse up and value change events for the control buttons?  I can't think of a good reason to use a mouse up event.

0 Kudos
Message 2 of 22
(1,889 Views)

I can't put control in the event case because I build my own GUI framework where I collect all controls referencies and pass it to Reg Events node. Please don't discuss that it's not the matter of my question.
Ditto for "MouseUp". That event was for testing purposes only.

No, I can't read value of button "Latch when released" with property node. It causes error. See:
https://forums.ni.com/t5/LabVIEW/unexpected-error-why/td-p/112580

Once more my problem:
I have button "Latch when released". I get its control ref and pass it to Reg Events node. Events structure catch button press. But button stay pressed. To reset button value its necessary to read its value inside event structure. It can't be done by property node (LV error 1193, see link above). And if read value by "NewVal" it doesn't reset button. THATS the problem.
I have found one solution: use "Switch...." mechanical action and reset button inside Event structure. However this solution needs to know if button is button only or switch (keeps value to next click).


*** LV2018 ***
0 Kudos
Message 3 of 22
(1,869 Views)

The curiosity is, that you can't use the value property, but you can get the value from the value change event and you can get the value also when using "OwningVI" followed by the invoke node "Control Value.Get".

 

In this scenario, you have to reset the button by yourself by writing the value "false" to the button.

 

0 Kudos
Message 4 of 22
(1,841 Views)
Solution
Accepted by topic author petrnowak

@petrnowak wrote:


I have found one solution: use "Switch...." mechanical action and reset button inside Event structure. However this solution needs to know if button is button only or switch (keeps value to next click).


Well that's exactly what I said to do in my message.  I'm glad you "found" that.

 

You can know which button actually changed.  You have New Value and and Old Value nodes on the border of the event case.  Compare them to each other with a Not Equals.  The element of the resulting cluster that is True will tell you which one changed.

0 Kudos
Message 5 of 22
(1,832 Views)

@RavensFan :  Yes, you were right. The only soliution is to use "Switch when released" and reset button.

I don't understand your last paragraph. I do know what button was pressed. I have control Ref inside Event structure. Or did you mean something else ???


*** LV2018 ***
0 Kudos
Message 6 of 22
(1,827 Views)

Compare the old value and new value of the cluster.

 

The one that changed will have be a True boolean.

 

 

 

0 Kudos
Message 7 of 22
(1,822 Views)

@RavensFan : I'm afraid I can't understand your example with cluster. What cluster? Where? How is it related to my example? How is "your" cluster related to my code example?


*** LV2018 ***
0 Kudos
Message 8 of 22
(1,818 Views)

You already have the reference to the Boolean control you have set for "switch when released".  All you have to do is use the value property node for it, inside its event case, to set it back to "FALSE".

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 22
(1,807 Views)

@petrnowak wrote:

@RavensFan : I'm afraid I can't understand your example with cluster. What cluster? Where? How is it related to my example? How is "your" cluster related to my code example?


Your example had a cluster of boolean buttons in it.

 

My example had a cluster of boolean buttons in it.

 

Is it that hard to see how my example would relate to your example?

0 Kudos
Message 10 of 22
(1,795 Views)