Technology area | Safari Extensions |
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 its eventPhase
property. When you register for an event notification, you specify whether you want to be notified during the capturing phase or not, so you may not always need to check what phase the event is in.
A Boolean value that indicates whether the event goes through the bubbling phase.
readonly attribute boolean bubbles
A Boolean value that indicates whether the event can be canceled.
readonly attribute boolean cancelable
The object that the event is currently being sent to.
readonly attribute SafariEventTarget currentTarget
This attribute varies as the event progresses through the phases, changing as the event moves through the event-dispatch hierarchy.
A Boolean value that indicates whether the default action has been prevented.
readonly attribute boolean defaultPrevented
A number that indicates which event-handling phase the event is in.
readonly attribute unsigned short eventPhase
The values for this property are the same as the values used by Webkit to identify the event-handling phases.
The target of the event.
readonly attribute SafariEventTarget target
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.
The time and date that the event was created.
readonly attribute DOMTimeStamp timeStamp
The type of the event.
readonly attribute DOMString type
The string used to identify a particular type of event is documented in the reference for that class.
Prevents the browser from performing the default action for the event.
void preventDefault()
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.
In the current implementation, there are no Safari Extensions events that have default actions associated with them.
Prevents the event from any further propagation.
void stopPropagation()
Propagation can only be stopped if an event is can be canceled. After propagation is stopped, the event is not sent to any other targets.
Last updated: 2010-07-02