Global Handlers (Magic xpa 4.x)
If a program in the host calls a component event and the handler for the event is in the main program of the component, the event will not be handled because the handler will not be in the current runtime task tree. However, if the handler has a global scope, the event will be handled, as shown in the figure below.
The question is, when will the global handler be handled? Let’s use the previous example, but this time we will substitute a global handler for the event handler in the main program of the component.
Once again, Program C raises the event, but the search for a handler, and the propagate sequence, is slightly different. The sequence is:
-
Program C
-
Program A
-
Host Main Program
-
Component Global Handler
As you can see, the global handlers are handled last in the runtime tree.
The main advantage of a global handler is to provide event default behavior for the entire application.
Important:
|
A global handler may be defined for an event that has not been defined in this component. You can even create a global handler for an Internal or a System event.
|