09-07-2020 02:08 PM
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....
Solved! Go to Solution.
09-07-2020 02:56 PM
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.
09-07-2020 03:37 PM
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).
09-07-2020 04:39 PM
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.
09-07-2020 05:30 PM
@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.
09-07-2020 05:44 PM
@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 ???
09-07-2020 06:01 PM - edited 09-07-2020 06:02 PM
Compare the old value and new value of the cluster.
The one that changed will have be a True boolean.
09-07-2020 06:22 PM
@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?
09-07-2020 07:06 PM - edited 09-07-2020 07:06 PM
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".
09-07-2020 08:07 PM
@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?