05-11-2016 11:25 AM
I have an application with a main VI, where five different subVIs are opened one at a time (dynamically opening VI). These SubVIs also have Vis running in modal state and default states(appears as different screens, some are modal and different windows).
I need to track F1 keydown event from all these SubVIs and serve the event in the first opened main VI using dynamic event concept.
I tried to register the keydown event by giving the VI reference just after opening the SubVI dynamically(Among those 5 subvi mentioned above) and its working. But how can I register events for the other subVIs which is not opening directly or dynamically from Main VI? If I try to register event for all those SubVIs in main VI itself, It gives me error as the subVI is not in running state. How can I dynamically change the event refnum? How can I include this in Main VI?
Any suggestions are greatly appreciated
05-11-2016 01:02 PM
I see 2 solutions
1) You can dynamically change object for which event is registered. First you register required number of events for some empty template vi (it can be a static reference) and describe them in events structure. Then, when you load your vis, you provide valid references to the register events node.
2 - I prefer this way) Main VI registers one User event. It's link is provided for subVIs as an input. They generate user event when needed (when key pressed, error happens, etc) and send VI (name) and event identification.