Searching for the Handler (Magic xpa 4.x)
When an event is triggered, the runtime tree is scanned from the bottom-most task up to the Main Program for a handler that corresponds to the triggered event. (The runtime tree is the collection of all the tasks that are currently running under the same context. The task order in the runtime tree is the order in which they were opened.) The engine sequentially executes the operations defined for the handler once it has been found. After executing the last operation in the handler, the engine continues up the runtime tree looking for another matching handler. After reaching the Main Program and executing any handlers found, when the triggered event is an internal event, the engine looks for internal engine handlers for the triggered event.
Handlers of the same event, which are defined in the same task, are executed according to their location in the Task Editor from the bottom upwards.