Safari Reference Library Apple Developer
Search

SafariEvent Class Reference

Technology area
Safari Extensions

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:

  1. 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.

  2. Targeting. The event is sent to its target.

  3. 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.

Tasks

Targeting Events

Interacting with Event Propagation

Preventing the Default Action

Properties

bubbles

A Boolean value that indicates whether the event goes through the bubbling phase.

readonly attribute boolean bubbles

cancelable

A Boolean value that indicates whether the event can be canceled.

readonly attribute boolean cancelable
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.

defaultPrevented

A Boolean value that indicates whether the default action has been prevented.

readonly attribute boolean defaultPrevented

eventPhase

A number that indicates which event-handling phase 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.

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.

timeStamp

The time and date that the event was created.

readonly attribute DOMTimeStamp timeStamp

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.

Methods

preventDefault

Prevents the browser from performing the default action for the event.

void preventDefault()

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.

In the current implementation, there are no Safari Extensions events that have default actions associated with them.

stopPropagation

Prevents the event from any further propagation.

void stopPropagation()

Discussion

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.

See Also



Last updated: 2010-07-02

Did this document help you? Yes It's good, but... Not helpful...