The first and most important step is to call the
initialize() method of the element whose events
you want to handle. This enables all the mechanisms that are internally used to capture events. Then setting up events is a two-step process.
Write an event handling function that is called when the event occurs.
Link the event handling function to the element using
Example 4-9 revisits the “three windows” example from Example 4-1, using Atlas event handling. The HTML buttons are referenced using the
Sys.UI.Button class, and the associated event is (obviously)
Example 4-9. Using Atlas Button control events
propertyChanged. It is used generically for all controls to indicate that something has changed: a key was pressed, a list item was selected, and so on.
It is also possible to work with individual change events for each form element so that you know exactly what has changed. For instance, when the selected element in a selection list changes, it raises the
change). Illustrating this event is once again an opportunity to rewrite one of the previous examples (see Example 4-7). This time, we do not have to periodically check the selection list for changes; instead, we capture the associated event. Remember to call
initialize(); otherwise, the event cannot be captured. Example 4-10 shows code that handles a
Example 4-10. Using Atlas selection list events
The performance of this code is much better than in the previous version of this example, since the application reacts immediately when the selection in the list is changed and not just at the end of each 1,000-millisecond interval.