| Adobe AIR 1.1 |
|
|
Listening for window eventsTo listen for the events dispatched by a window, register a listener with the window instance. For example, to listen for the closing event, register a listener with the window as follows: window.nativeWindow.addEventListener(air.Event.CLOSING, onClosingEvent); When an event is dispatched, the target property references the window sending the event. Most window events have two related messages. The first message signals that a window change is imminent (and can be canceled), while the second message signals that the change has occurred. For example, when a user clicks the close button of a window, the closing event message is dispatched. If no listeners cancel the event, the window closes and the close event is dispatched to any listeners. Typically, the warning events, such as closing, are only dispatched when system chrome has been used to trigger an event. Calling the window close() method, for example, does not automatically dispatch the closing event—only the close event is dispatched. You can, however, construct a closing event object and dispatch it using the window dispatchEvent() method. The window events that dispatch an Event object are:
The window events that dispatch an NativeWindowBoundsEvent object are:
For NativeWindowBoundsEvent events, you can use the beforeBounds and afterBounds properties to determine the window bounds before and after the impending or completed change. The window events that dispatch an NativeWindowDisplayStateEvent object are:
For NativeWindowDisplayStateEvent events, you can use the beforeDisplayState and afterDisplayState properties to determine the window display state before and after the impending or completed change. |