Defining And Registering Event Handlers - Adobe GoLive CS2 Programmer's Manual

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide
Other events allow more specialized responses, such as defining the appearance of a custom control
when it needs to be redrawn (see
For a complete list of events and the circumstances that generate them, see
Handlers" in the GoLive CS2 SDK Programmer's Reference.
Note:
Event handling has changed significantly in this release. See
Handlers

Defining and Registering Event Handlers

You must register a handler for a specific event in each event target object that should respond to that
event. For example, if your extension defines two menu items, you could register a handler to respond to
the
menuSignal
function to register for a specific event in that object.
An event handler takes a single argument, the event object. You can define an event handler as a
separate named function, or you can define it inline during registration. Inline code can be a locally
defined function that takes the event-object argument, or a simple statement.
For example, supposing that your extension adds a menu item with the name doThisItem to the Hello
menu, you can register an event handler for the item in any of the following ways:
To define the handler as a separate function:
//define the handler function
function doThisHandler (menuEvt) {
Window.alert ("You chose" + menuEvt.name);
}
//register the handler for a target
function initializeModule() {
menubar['Hello'].items['doThisItem'].addEventListener( 'menuSignal',
}
To define the handler inline during registration:
// register a locally-defined function
function initializeModule() {
menubar['Hello'].items['doThisItem'].addEventListener( 'menuSignal',
}
—or—
// register inline source code
function initializeModule() {
menubar['Hello'].items['doThisItem'].addEventListener( 'menuSignal',
}
It is possible to register an event handler at any time. You can, for convenience, use your extension's
initialization function to register your handlers:
// Register event handler
function initializeModule() {
menubar['Hello'].items['doThisItem'].addEventListener( 'menuEvent',
in the GoLive CS2 SDK Programmer's Reference.
in each of the
menuItem
doThisHandler)
function (e) {'Window.alert ("You chose" + e.name);'})
'Window.alert ("You chose the Do This menu item")')
Adobe GoLive CS2 SDK
Chapter 6, "Custom
Elements").
Objects. Use the event target object's
The JavaScript Environment
Chapter 3, "Events and Event
Compatibility with Previous Event
addEventListener
33

Advertisement

Table of Contents
loading

Table of Contents