Class: Event

Event(type, bubblesopt, cancelableopt)

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)

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.
Source:
Example
const evt = new Event("myEvent");
const dispatcher = new EventDispatcher();
dispatcher.on("myEvent", event => console.log(event.type));
dispatcher.dispatchEvent(evt); // logs "myEvent"

Members

Name Description
bubbles Indicates whether the event will bubble through the display list.
cancelable Indicates whether the default behaviour of this event can be cancelled via core.Event#preventDefault.
currentTarget 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).
defaultPrevented Indicates if core.Event#preventDefault has been called on this event.
eventPhase 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
immediatePropagationStopped Indicates if core.Event#stopImmediatePropagation has been called on this event.
propagationStopped Indicates if core.Event#stopPropagation or core.Event#stopImmediatePropagation has been called on this event.
removed Indicates if core.Event#remove has been called on this event.
target The object that generated an event.
timeStamp The epoch time at which this event was created.
type The type of event.


Methods

Name Description
clone Returns a clone of the Event instance.
preventDefault 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.
remove Causes the active listener to be removed via removeEventListener();
set Provides a return {core.Event} this, chainable shortcut method for setting a number of properties on the instance.
stopImmediatePropagation Sets core.Event#propagationStopped and core.Event#immediatePropagationStopped to true. Mirrors the DOM event standard.
stopPropagation Sets core.Event#propagationStopped to true. Mirrors the DOM event standard.
toString Returns a string representation of this object.


clone() → {core.Event}

Returns a clone of the Event instance.
Source:
Returns:
a clone of the Event instance.
Type
core.Event

preventDefault() → {core.Event}

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.
Source:
Returns:
this, chainable
Type
core.Event

remove() → {core.Event}

Causes the active listener to be removed via removeEventListener();
Source:
Returns:
this, chainable
Type
core.Event
Example
myBtn.addEventListener("click", event => {
  event.remove(); // removes this listener.
});

set(props) → {core.Event}

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.
Source:
Returns:
this, chainable
Type
core.Event

stopImmediatePropagation() → {core.Event}

Sets core.Event#propagationStopped and core.Event#immediatePropagationStopped to true. Mirrors the DOM event standard.
Source:
Returns:
this, chainable
Type
core.Event

stopPropagation() → {core.Event}

Sets core.Event#propagationStopped to true. Mirrors the DOM event standard.
Source:
Returns:
this, chainable
Type
core.Event

toString() → {string}

Returns a string representation of this object.
Source:
Returns:
A string representation of the instance.
Type
string