Event

Event

Contains properties and methods shared by all events for use with core.EventDispatcher. Note that Event objects are often reused, so you should never rely on an event object's state outside of the call stack it was received in.

Constructor

new Event(type, bubblesopt, cancelableopt)

Source:
Example
const evt = new Event("myEvent");
const dispatcher = new EventDispatcher();
dispatcher.on("myEvent", event => console.log(event.type));
dispatcher.dispatchEvent(evt); // logs "myEvent"
Parameters:
Name Type Attributes Default Description
type string

The event type.

bubbles boolean <optional>
false

Indicates whether the event will bubble through the display list.

cancelable boolean <optional>
false

Indicates whether the default behaviour of this event can be cancelled.

Members

(readonly) bubbles :boolean

Source:

Indicates whether the event will bubble through the display list.

Type:
  • boolean

(readonly) cancelable :boolean

Source:

Indicates whether the default behaviour of this event can be cancelled via core.Event#preventDefault.

Type:
  • boolean

(readonly) currentTarget :Object

Source:
Default Value:
  • null

The current target that a bubbling event is being dispatched from. For non-bubbling events, this will always be the same as target. For example, if childObj.parent = parentObj, and a bubbling event is generated from childObj, then a listener on parentObj would receive the event with target=childObj (the original target) and currentTarget=parentObj (where the listener was added).

Type:
  • Object

(readonly) defaultPrevented :boolean

Source:
Default Value:
  • false

Indicates if core.Event#preventDefault has been called on this event.

Type:
  • boolean

(readonly) eventPhase :number

Source:
Default Value:
  • 0

For bubbling events, this indicates the current event phase:

  1. capture phase: starting from the top parent to the target
  2. at target phase: currently being dispatched from the target
  3. bubbling phase: from the target to the top parent
Type:
  • number

(readonly) immediatePropagationStopped :boolean

Source:
Default Value:
  • false

Indicates if core.Event#stopImmediatePropagation has been called on this event.

Type:
  • boolean

(readonly) propagationStopped :boolean

Source:
Default Value:
  • false

Indicates if core.Event#stopPropagation or core.Event#stopImmediatePropagation has been called on this event.

Type:
  • boolean

(readonly) removed :boolean

Source:
Default Value:
  • false

Indicates if core.Event#remove has been called on this event.

Type:
  • boolean

(readonly) target :Object

Source:
Default Value:
  • null

The object that generated an event.

Type:
  • Object

(readonly) timeStamp :number

Source:

The epoch time at which this event was created.

Type:
  • number

type :string

Source:

The type of event.

Type:
  • string

Methods

clone() → {core.Event}

Source:

Returns a clone of the Event instance.

Returns:

a clone of the Event instance.

Type
core.Event

preventDefault() → {core.Event}

Source:

Sets core.Event#defaultPrevented to true if the event is cancelable. Mirrors the DOM level 2 event standard. In general, cancelable events that have preventDefault() called will cancel the default behaviour associated with the event.

Returns:

this, chainable

Type
core.Event

remove() → {core.Event}

Source:

Causes the active listener to be removed via removeEventListener();

Example
myBtn.addEventListener("click", event => {
  event.remove(); // removes this listener.
});
Returns:

this, chainable

Type
core.Event

set(props) → {core.Event}

Source:

Provides a return {core.Event} this, chainable shortcut method for setting a number of properties on the instance.

Parameters:
Name Type Description
props Object

A generic object containing properties to copy to the instance.

Returns:

this, chainable

Type
core.Event

stopImmediatePropagation() → {core.Event}

Source:

Sets core.Event#propagationStopped and core.Event#immediatePropagationStopped to true. Mirrors the DOM event standard.

Returns:

this, chainable

Type
core.Event

stopPropagation() → {core.Event}

Source:

Sets core.Event#propagationStopped to true. Mirrors the DOM event standard.

Returns:

this, chainable

Type
core.Event

toString() → {string}

Source:

Returns a string representation of this object.

Returns:

A string representation of the instance.

Type
string