API Documentation for: 0.6.1
Show:

MouseEvent Class

Defined in: MouseEvent:34
Module: EaselJS

This is passed as the parameter to mousedown, mouseup, mousemove, stagemouseup, stagemousedown, mouseover, mouseout and click events on DisplayObject instances.

Constructor

MouseEvent

(
  • type
  • stageX
  • stageY
  • target
  • nativeEvent
  • pointerID
  • primary
  • rawX
  • rawY
)

Defined in MouseEvent:34

Parameters:

  • type String

    The event type.

  • stageX Number

    The normalized x position relative to the stage.

  • stageY Number

    The normalized y position relative to the stage.

  • target DisplayObject

    The display object this event relates to. Note that this will be overwritten when the event is dispatched via EventDispatcher.

  • nativeEvent MouseEvent

    The native DOM event related to this mouse event.

  • pointerID Number

    The unique id for the pointer.

  • primary Boolean

    Indicates whether this is the primary pointer in a multitouch environment.

  • rawX Number

    The raw x position relative to the stage.

  • rawY Number

    The raw y position relative to the stage.

Methods

addEventListener

(
  • type
  • listener
)
Function | Object

Adds the specified event listener. Note that adding multiple listeners to the same function will result in multiple callbacks getting fired.

Example

 displayObject.addEventListener("click", handleClick);
 function handleClick(event) {
    // Click happened.
 }

Parameters:

  • type String

    The string type of the event.

  • listener Function | Object

    An object with a handleEvent method, or a function that will be called when the event is dispatched.

Returns:

Function | Object: Returns the listener for chaining or assignment.

clone

() MouseEvent

Defined in clone:201

Returns a clone of the MouseEvent instance.

Returns:

MouseEvent: a clone of the MouseEvent instance.

dispatchEvent

(
  • eventObj
  • [target]
)
Boolean

Dispatches the specified event to all listeners.

Example

 // Use a string event
 this.dispatchEvent("complete");

 // Use an object
 var event = {
     type: "complete",
     foo: "bar"
 };
 this.dispatchEvent(event);

Parameters:

  • eventObj Object | String

    An object with a "type" property, or a string type. If a string is used, dispatchEvent will construct a generic event object with the specified type.

  • [target] Object optional

    The object to use as the target property of the event object. This will default to the dispatching object.

Returns:

Boolean: Returns true if any listener returned true.

hasEventListener

(
  • type
)
Boolean

Indicates whether there is at least one listener for the specified event type.

Parameters:

  • type String

    The string type of the event.

Returns:

Boolean: Returns true if there is at least one listener for the specified event.

initialize

() protected

Inherited from EventDispatcher but overwritten in initialize:183

Initialization method.

removeAllEventListeners

(
  • [type]
)

Removes all listeners for the specified type, or all listeners of all types.

Example

 // Remove all listeners
 displayObject.removeAllEvenListeners();

 // Remove all click listeners
 displayObject.removeAllEventListeners("click");

Parameters:

  • [type] String optional

    The string type of the event. If omitted, all listeners for all types will be removed.

removeEventListener

(
  • type
  • listener
)

Removes the specified event listener.

Important Note: that you must pass the exact function reference used when the event was added. If a proxy function, or function closure is used as the callback, the proxy/closure reference must be used - a new proxy or closure will not work.

Example

 displayObject.removeEventListener("click", handleClick);

Parameters:

  • type String

    The string type of the event.

  • listener Function | Object

    The listener function or object.

toString

() String

Inherited from EventDispatcher but overwritten in toString:210

Returns a string representation of this object.

Returns:

String: a string representation of the instance.

Properties

_listeners

Object protected

Inherited from EventDispatcher: _listeners:90

nativeEvent

MouseEvent

Defined in nativeEvent:117

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

onMouseMove

Function deprecated

Defined in onMouseMove:127

Deprecated: In favour of the "mousemove" event. Will be removed in a future version.

For events of type "onPress" only you can assign a handler to the onMouseMove property. This handler will be called every time the mouse is moved until the mouse is released. This is useful for operations such as drag and drop.

onMouseUp

Function deprecated

Defined in onMouseUp:137

Deprecated: In favour of the "mouseup" event. Will be removed in a future version.

For events of type "onPress" only you can assign a handler to the onMouseUp property. This handler will be called every time the mouse is moved until the mouse is released. This is useful for operations such as drag and drop.

pointerID

Number

Defined in pointerID:155

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

Defined in primary:163

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.

rawX

Number

Defined in rawX:93

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

Defined in rawY:101

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

Defined in stageX:79

The normalized x position on the stage. This will always be within the range 0 to stage width.

stageY

Number

Defined in stageY:86

The normalized y position on the stage. This will always be within the range 0 to stage height.

target

DisplayObject

Defined in target:147

The display object this event relates to.

Default: null

type

String

Defined in type:109

The type of mouse event. This will be the same as the handler it maps to (onPress, onMouseDown, onMouseUp, onMouseMove, or onClick).

Events

mousemove

Defined in mousemove:57

Available since 0.6.0

For MouseEvent objects of type "mousedown", mousemove events will be dispatched from the event object until the user releases the mouse anywhere. This enables you to listen to mouse move interactions for the duration of a press, which can be very useful for operations such as drag and drop. See the MouseEvent class for a listing of event properties.

mouseup

Defined in mouseup:67

Available since 0.6.0

For MouseEvent objects of type "mousedown", a mouseup event will be dispatched from the event object when the user releases the mouse anywhere. This enables you to listen for a corresponding mouse up from a specific press, which can be very useful for operations such as drag and drop. See the MouseEvent class for a listing of event properties.