LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

enable, disable and re-enable an event

Solved!
Go to solution

@crossrulz wrote:
Actually, not being registered for the event fixes this issue.  If the event has a lot of data in it, each event structure that is registered for it has a copy of the data.  By unregistering for the event, you are eliminating a copy of the data.  With using the flag, you still have that copy happening.

 

Personally, I do not see one any more complicated than the other.  But I would say the unregistering for the event is the more efficient one.


That's two different topics.  Yes, it will have a copy of the data.  Copying data, in itself, isn't a memory leak.  It might be less efficient.  But, it's also easier to grasp.  It's easier to look now at how to register/unregister events and create your own.  When you first start with event structures, they're already a bit of a challenge to pick up.  Adding the extra steps doesn't make it easier.  It makes it a bit more complex.  As you'll see from future posts, the flag is still a new concept to the OP.  Overwhelming them with something that offers efficiency in specific cases isn't likely to be the best route, especially if we're mistating efficiency as memory leaks.

 

 

In terms of what a flag is: it's just a boolean.  You set it to what you want to happen.  "Process Events?"  Set it to true when you want the event to process and false when you don't.  Inside of the event, you just feed that value into a case structure that has a false empty case.  In the false event, you don't want anything to happen.  The event triggers but there is nothing taking place.  In the true case, you have your event handling code.  The event fires and processes the code.

 

If you'd like to look at efficiency, do a quick search for "user events labview" and you'll find a decent amount of documentation explaining the other method mentioned in this thread.

0 Kudos
Message 11 of 16
(2,858 Views)

events14.png

0 Kudos
Message 12 of 16
(2,849 Views)
Solution
Accepted by topic author AlehTH

---------

I need to move through the rows of the multicolumn box, and pressing "ENT" listbox appears, and pressing "DOWN" selection moves in the listbox, NOT in the multicolumn box, for this I need to disable the event "Ok Button 2 : Value Change "... I attached the vi to you understand me better.

---------

 

Why you think reg/unreg events?
You case is "flags".
If ENT pressed, you work with listbox. Another case work with multicolumn listbox.

ev4.png

 

ev5.png

Message 13 of 16
(2,838 Views)
Solution
Accepted by topic author AlehTH

Based on the VI posted by AlehTH and the explanation of the desired action, I wrote down the behavior required. Is this what you want the program to do?

 

Initialize: Set item names
               Set MC Listbox to default = 0
               Set Listbox to Invisible (flag)
Wait for event:
               Stop: Stop the loop.
               Up: If Listbox = Invisible, then Decrement MC Listbox
                                                       else Decrement Listbox
               Down: If Listbox = Invisible, then Increment MC Listbox
                                                            else Increment Listbox
                Ent: Toggle Listbox visibility.

 

To implement this logic does not require User Events or "turning off" any event. It does require one "flag." That flag is the Visibility status of the Listbox.

 

Both the Listbox and the Multicolumn (MC) Listbox are changed to indicators. The only way to chage their values is by using the buttons.

 

The Initialize process occurs in the Timeout case of the event structure. The timeout value is connected via shift register so this case executes immediately when the program starts and then never again.

 

Property nodes are only used in the Timeout case to initialize the listboxes and in the "ENT" case to change the Listbox visibility. Value property nodes are very rarely required and certainly not in this situation.

 

The Event Cases for the UP and DOWN buttons change the values of the Multicolumn Listbox if the Listbox is Invisible or the Listbox if it is visible. Both limit the range of values to those which which show on the panel. The ENT button Event Case changes the visibility and places the visibility "flag" on a shift register.

 

Lynn

Message 14 of 16
(2,829 Views)

AlehTH wrote:  for this I need to disable the event "Ok Button 2 : Value Change "...

If that is all you need, then just disable the button and be done with it.  That would be BY FAR the simplest solution.


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 15 of 16
(2,807 Views)

Thanks to all!, The answer of each one helped me soo much. 

0 Kudos
Message 16 of 16
(2,782 Views)