MouseEvent Class
Passed as the parameter to all mouse/pointer/touch related events. For a listing of mouse events and their properties, see the DisplayObject and Stage event listings.
Constructor
MouseEvent
-
type
-
bubbles
-
cancelable
-
stageX
-
stageY
-
nativeEvent
-
pointerID
-
primary
-
rawX
-
rawY
-
relatedTarget
Parameters:
-
type
StringThe event type.
-
bubbles
BooleanIndicates whether the event will bubble through the display list.
-
cancelable
BooleanIndicates whether the default behaviour of this event can be cancelled.
-
stageX
NumberThe normalized x position relative to the stage.
-
stageY
NumberThe normalized y position relative to the stage.
-
nativeEvent
MouseEventThe native DOM event related to this mouse event.
-
pointerID
NumberThe unique id for the pointer.
-
primary
BooleanIndicates whether this is the primary pointer in a multitouch environment.
-
rawX
NumberThe raw x position relative to the stage.
-
rawY
NumberThe raw y position relative to the stage.
-
relatedTarget
DisplayObjectThe secondary target for the event.
Item Index
Methods
clone
()
MouseEvent
Returns a clone of the MouseEvent instance.
Returns:
a clone of the MouseEvent 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
bubbles
Boolean
readonly
Indicates whether the event will bubble through the display list.
Default: false
cancelable
Boolean
readonly
Indicates whether the default behaviour of this event can be cancelled via preventDefault. This is set via the Event constructor.
Default: false
currentTarget
Object
readonly
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
defaultPrevented
Boolean
readonly
Indicates if preventDefault has been called on this event.
Default: false
eventPhase
Number
readonly
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
readonly
Indicates if stopImmediatePropagation has been called on this event.
Default: false
isTouch
Boolean
readonly
Indicates whether the event was generated by a touch input (versus a mouse input).
localX
Number
readonly
Returns the x position of the mouse in the local coordinate system of the current target (ie. the dispatcher).
localY
Number
readonly
Returns the y position of the mouse in the local coordinate system of the current target (ie. the dispatcher).
nativeEvent
HtmlMouseEvent
The native MouseEvent generated by the browser. The properties and API for this event may differ between browsers. This property will be null if the EaselJS property was not directly generated from a native MouseEvent.
Default: null
pointerID
Number
The unique id for the pointer (touch point or cursor). This will be either -1 for the mouse, or the system supplied id value.
primary
Boolean
Indicates whether this is the primary pointer in a multitouch environment. This will always be true for the mouse. For touch pointers, the first pointer in the current stack will be considered the primary pointer.
propagationStopped
Boolean
readonly
Indicates if stopPropagation or stopImmediatePropagation has been called on this event.
Default: false
rawX
Number
The raw x position relative to the stage. Normally this will be the same as the stageX value, unless stage.mouseMoveOutside is true and the pointer is outside of the stage bounds.
rawY
Number
The raw y position relative to the stage. Normally this will be the same as the stageY value, unless stage.mouseMoveOutside is true and the pointer is outside of the stage bounds.
stageX
Number
The normalized x position on the stage. This will always be within the range 0 to stage width.
stageY
Number
The normalized y position on the stage. This will always be within the range 0 to stage height.