Home > Element Reference : Handler

Contents

### Handler

Specifies event handlers which the XBL element responds to. You can provide default handling which can be overriden by an appropriate handler on the bound element. When the event occurs, the code contained in the action attribute or, if the action is not present, the content of the handler tag is executed.

More information about Handler

Example:

        <handler event="keydown" keycode="VK_F3">
          alert('You pressed the F3 key! Good for you!');
        </handler>

#### Attributes:

Attributes inherited from Element

action

The code contained in the action value is executed when the event occurs.

button

If set, the action is only called when the given mouse button is pressed. If this attribute is not used, it does not matter which button is pressed.

- 0: the left mouse button
- 1: the middle mouse button
- 2: the right mouse button

capturing
charcode

If set, the action is only called when the given character is pressed. If the key is not pressed, the event is ignored by this handler. If this attribute is not present and there is no keycode attribute, the handler is called no matter which key is pressed.

class

The style class of the xbl:handler. Multiple classes may be specified by separating them with spaces.

clickcount

Set to the number of mouse clicks that must occur for the action to be called. For example, if set to 2, the handler only get called on a double click of the mouse. Mozilla supports values 1, 2 and 3. The default is 1.

event

The event that the handler listens to. When the event occurs on the bound element, the code in the action attribute is executed. Two special events exist, bindingattached, which is called when the binding is bound to an element, and bindingdetached, which is called when the binding is removed from an element.

id

A unique identifier so that you can identify the xbl:handler with. You can use this as a parameter to getElementById and other DOM functions and to reference the element in style sheets.

keycode

If set, the action is only called for a key event when the key with the given code is pressed.

modifiers

A list of modifier keys that should be pressed to invoke the handler. Multiple keys may be separated by spaces or commas. Keys will map to other keys on platforms that do not have them.

- shift: The Shift key.
- alt: The Alt key. On the Macintosh, this is the Option key.
- meta: The Meta key. On the Macintosh, this is the Command key.
- control: The Control key.
- accel: The key used for keyboard shortcuts on the user's platform. Usually, this would be the value you would use.

phase

The event phase where the handler is invoked. This should be set to the value 'capturing' to indicate during the event capturing phase or left out entirely.

Copyright (C) 1999 - 2002 XULPlanet.com