Event Class
Contains properties and methods shared by all events for use with 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
Item Index
Methods
clone
()
Event
Returns a clone of the Event instance.
Returns:
a clone of the Event instance.
preventDefault
()
Sets 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();
myBtn.addEventListener("click", function(evt) {
// do stuff...
evt.remove(); // removes this listener.
});
set
-
props
Provides a chainable shortcut method for setting a number of properties on the instance.
Parameters:
-
props
ObjectA generic object containing properties to copy to the instance.
Returns:
Returns the instance the method is called on (useful for chaining calls.)
stopImmediatePropagation
()
Sets propagationStopped and immediatePropagationStopped to true. Mirrors the DOM event standard.
Properties
cancelable
Boolean
Indicates whether the default behaviour of this event can be cancelled via preventDefault. This is set via the Event constructor.
Default: false
currentTarget
Object
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).
Default: null
eventPhase
Number
For bubbling events, this indicates the current event phase:
- capture phase: starting from the top parent to the target
- at target phase: currently being dispatched from the target
- bubbling phase: from the target to the top parent
Default: 0
immediatePropagationStopped
Boolean
Indicates if stopImmediatePropagation has been called on this event.
Default: false
propagationStopped
Boolean
Indicates if stopPropagation or stopImmediatePropagation has been called on this event.
Default: false