I am sitting here in the first day of "Core 2." It's been mostly review for me, but I just learned about "Notify Events." The instructor tried to describe when you would use a filter event vs. a notify event, but I still haven't been able to wrap my brain around the difference. Can anyone point me to some real world examples of when you would use a notify event and when you would use a filter event?
Solved! Go to Solution.
Filter events occur before notify events. This means in turn, you can you a filter event to discard a notify event. See here.
An example on how to use a filter event can be taken from the template vi "Dialog Using Events" which discards the "Panel Close" event by discarding it in the "Panel Close?" event.
Notify events are the ones you are most likley familliar with like Control-Value Changed Use these when you want to do something specific each time a user does something. A "STOP" Boolean in a Value change event that causes the event structure to output a TRUE value wired to the While loop containing that Event structure is fairly common.
Filter events all end with a ? These are events that usually do MORE than trigger the event structure. FP Close? is a good example of this. Your user expects the "Normal Window" behavior that clicking the red windows X causes the App to stop. But your app may not be in a good condition to close (hardware on, memory not cleaned up, data not saved etc...) the Filter event can TRAP this event before the application closes. You code then can determine if it is safe to close and allow the event to be acted on normally or, discard the event and trigger your app to start a safe and controlled shutdown before exiting. MS Office apps use these to to prompt you to save files when you X out.
Averna Automated Test Systems
Common reasons for using a filter event are when you either want to discard the event entirely in some circumstances, or you want to do something different than what the event would normally do.
One very common filter event is Panel Close? Often you want to do some cleanup before the window actually closes, so you discard the event, run your shutdown code, and then exit the application programmatically. There's also a Panel Close notifier event, but that's not very useful within a single VI because by the time it occurs, your VI has been closed. The Panel Close notifier event is useful when you've registered for events on some other VI or are otherwise holding a reference to the VI that will keep it from closing when the panel closes.
Key Down is an example where you might sometimes use a filter event and other times use a notify event. You would use a filter event if you need to take some action that doesn't match what a key would normally do - for example, you might need to handle the Tab key differently if you don't want the default focus change behavior. You would use a notify event if you want to catch all keystrokes and allow LabVIEW to handle them normally, but still keep track of the event. Let's say you want to catch every keystroke in a text box and send it over the serial connection - you could do this by handling the Key Down notifier event.
Nofity perform the event action i.e. the UI notifies LV runtime of value change, mouse click etc and labview peform code in event structure.
Filter notify does not immediately notify LV of value change, but allows option to cancel notification to LV runtime of mouse click, value change etc.