Routed Events

LANSA Version 13 SP2

Routed Events


To simplify the coding of complex reusable parts and in particular the design panels for the new user- designed controls, an event detected on a control is now passed up the parent chain.

Typically for user-designed control, the panels displayed are constructed of little more than labels and images. However, with the existing event processing, each of the labels would take the click event and not pass it on. The result would be that the user would need to code every click event for every child control. By routing the event up the parent chain, coding is greatly simplified.

Of course, it may be necessary to know which of the controls actually fire the event initially. The EVTROUTINE command already has the Com_Sender selector, but this only ever reports the control firing the event. So, the Origin selector has been added. Regardless of how many layers of parent are used, Origin will contain a reference to the instance on which the event was actually started.

Evtroutine Handling(#Com_owner.Click) Origin(#Origin)

Endroutine

 

The only exception to this rule is when the event crosses a reusable part boundary. Reusable parts are black boxes as such and the rules of encapsulation dictate that what goes on within a reusable part must stay within a reusable part. So, in this situation, as far as the parent is concerned, the origin is the reusable part itself.

As at the time of release of this document, the Origin control is still available across the reusable part boundary. This is a known issue.

Clearly though, this change of event behavior may have some side effects. In a simple example where there is a click event for both child and parent components, in Win32 the two events would remain separate. However, with DirectX processing and event routing a click on the child would result in both the child click and parent click firing. This is an unusual situation and it is unlikely that many customers will encounter it, but nevertheless it is conceivable and should be catered for.

To counter unwanted event propagation, the Handled Selector has been added to EVTROUTINE. By setting Handled to true the event is no longer passed beyond the routine being processed.

Evtroutine Handling(#Button.Click) Handled(#Handled)

* Stop the event going any further up the parent chain.

#Handled := True

Endroutine