SafariEvent Class Reference
| Technology area | Safari Extensions |
| Availability | Available in Safari 5.0 and later. |
Overview
The SafariEvent class is a base class used to encapsulate events. Developers who are familiar with DOM events will notice many similarities in design and behavior.
Events are sent to their target and its ancestors in three phases. In order, they are as follows:
Capturing. The event is sent to every ancestor of the its target, starting with the most distant ancestor, and ending with the parent of the event’s target.
Targeting. The event is sent to its target.
Bubbling. The event is sent to every ancestor of its target, starting with the parent of the event’s target, and ending with its most distant ancestor.
You can tell which phase an event is in from the value of its eventPhase property. When you register for an event notification, you specify whether or not you want to be notified during the capturing phase. Therefore, you may not always need to check what phase the event is in.
Properties
bubbles
A Boolean value that indicates whether the event goes through the bubbling phase.
readonly attribute boolean bubbles
Availability
- Available in Safari 5.0 and later.
cancelable
A Boolean value that indicates whether the event can be canceled.
readonly attribute boolean cancelable
Availability
- Available in Safari 5.0 and later.
See Also
currentTarget
The object that the event is currently being sent to.
readonly attribute SafariEventTarget currentTarget
Discussion
This attribute varies as the event progresses through the phases, changing as the event moves through the event-dispatch hierarchy.
Availability
- Available in Safari 5.0 and later.
defaultPrevented
A Boolean value that indicates whether the event’s default action has been prevented.
readonly attribute boolean defaultPrevented
Availability
- Available in Safari 5.0 and later.
eventPhase
The event-handling phase that the event is in.
readonly attribute unsigned short eventPhase
Discussion
The values for this property are the same as the values used by Webkit to identify the event-handling phases. See “Event Handling Phases.”
Availability
- Available in Safari 5.0 and later.
target
The target of the event.
readonly attribute SafariEventTarget target
Discussion
This attribute stays the same as the event moves through the event-dispatch hierarchy. Its value is the same as the object that the event is sent to during the targeting phase.
Availability
- Available in Safari 5.0 and later.
timeStamp
The time and date that the event was created.
readonly attribute DOMTimeStamp timeStamp
Availability
- Available in Safari 5.0 and later.
type
The type of the event.
readonly attribute DOMString type
Discussion
The string used to identify a particular type of event is documented in the reference for that class.
Availability
- Available in Safari 5.0 and later.
Methods
preventDefault
Prevents the browser from performing the default action for an event.
Discussion
Use this method to indicate that your extension has already fully handled the event; you don’t want the browser to do anything. Note that preventing the default action does not stop an event from propagating.
Availability
- Available in Safari 5.0 and later.
stopPropagation
Prevents the event from any further propagation.
Discussion
Propagation can be stopped only fon cancelable events. After propagation is stopped, the event is not sent to any other targets.
Availability
- Available in Safari 5.0 and later.
See Also
Constants
Event-Handling Phases
Phases of the event-handling process.
Constants
BUBBLING_PHASEThe bubbling phase.
Available in Safari 5.1 and later.
CAPTURING_PHASEThe capturing phase.
Available in Safari 5.1 and later.
TARGETING_PHASEThe targeting phase.
Available in Safari 5.1 and later.
© 2011 Apple Inc. All Rights Reserved. (Last updated: 2011-05-09)