Handler Hierarchy (Magic xpa 4.x)
The previous section described how several handlers could handle the same event. These handlers can be defined in various tasks that are part of the runtime tree. They are executed according to their hierarchy in the runtime tree. The handler defined in the lowest level of a task is executed first. The handler defined in the Main Program, or internally in the engine when dealing with Internal events, is executed last.
You can use the hierarchical handler structure and define high-level handlers for several different tasks. A handler defined in one program, Program A, is available for all other programs and subtasks called from Program A.
Tip:
|
The Main Program is the parent program of all other programs in the project, and it is always at the top of the runtime tree at runtime. This means that a handler defined in the Main Program is a global handler for the entire project.
|
Example: If you want to let the end-user check the current date by pressing Ctrl+D anywhere in the application, you can define a handler on the Ctrl+D System event and define the appropriate logic within the handler to display the current date.
The handler hierarchy lets you create high-level logic that can be used and re-used throughout the project. In addition, working with high-level handlers makes maintenance easier because modifications are performed in one place.