C.3. Event Attributes

Table of Contents
onblur -- //FIXME purpose should go here
onbroadcast -- //FIXME purpose should go here
onchange -- //FIXME purpose should go here
onclick -- //FIXME purpose should go here
onclose -- //FIXME purpose should go here
oncommand -- //FIXME purpose should go here
oncommandupdate -- //FIXME purpose should go here
oncontextmenu -- //FIXME purpose should go here
oncreate -- //FIXME purpose should go here
ondblclick -- //FIXME purpose should go here
ondestroy -- //FIXME purpose should go here
ondragdrop -- //FIXME purpose should go here
ondragenter -- //FIXME purpose should go here
ondragexit -- //FIXME purpose should go here
ondraggesture -- //FIXME purpose should go here
ondragover -- //FIXME purpose should go here
onfocus -- //FIXME purpose should go here
oninput -- //FIXME purpose should go here
onkeydown -- //FIXME purpose should go here
onkeypress -- //FIXME purpose should go here
onkeyup -- //FIXME purpose should go here
onload -- //FIXME purpose should go here
onmousedown -- //FIXME purpose should go here
onmousemove -- //FIXME purpose should go here
onmouseout -- //FIXME purpose should go here
onmouseover -- //FIXME purpose should go here
onmouseup -- //FIXME purpose should go here
onoverflow -- //FIXME purpose should go here
onoverflowchanged -- //FIXME purpose should go here
onpopuphidden -- //FIXME purpose should go here
onpopuphiding -- //FIXME purpose should go here
onpopupshowing -- //FIXME purpose should go here
onpopupshown -- //FIXME purpose should go here
onselect -- //FIXME purpose should go here
onunderflow -- //FIXME purpose should go here
onunload -- //FIXME purpose should go here

Events are built-in constructs that are part of the interaction between JavaScript and HTML. These constructs have been crucial to DHTML for many years. They are designed to capture and handle actions triggered by the user, such as a mouse click or the pressing of a certain key. Event handlers have been brought into the world of XUL/XBL and allow dynamic, interactive Mozilla applications. In XUL, events can exist on any attribute, and typically bubble up through the hierarchy. An event attribute of the empty string generates a JS strict warning (if this is turned on in the user preferences), and removing an event attribute from a XUL event does not remove the event listener (although it does in HTML).

The events are listed in the form on<eventName>, which is how events are used as attributes on XUL elements. The attribute contains lines of script or a function call, when a script is too long. Here is an example of an event attribute that carries out a function each time a menulist value changes:

<menulist id="eventList" editable="true" flex="1" onchange="addEvent(this)">

The syntax is different in XBL. Here the event is specified as the value of the name attribute, which is attached to the handler element. One or more of these elements can optionally be contained in a binding. The given value is the event's name, minus the "on" prefix. The executed code is contained in the body of the handler inline, or in the action attribute, as shown in this example:

<handler name="focus" action="this.activate( )"/>

Chapter 7 provides a closer look at events in XBL. All the events listed here are available for use in XUL and XBL.