MouseInteractionManager

MouseInteractionManager

Handle mouse interaction events for a Canvas object. There are three phases of events: hover, click, and drag

Hover Events: _handleMouseOver action: hoverIn _handleMouseOut action: hoverOut

Left Click and Double-Click _handleMouseDown action: clickLeft action: clickLeft2

Right Click and Double-Click _handleRightDown action: clickRight action: clickRight2

Drag and Drop _handleMouseMove action: dragLeftStart action: dragLeftMove action: dragRightStart action: dragLeftMove _handleMouseUp action: dragLeftDrop action: dragRightDrop _handleDragCancel action: dragLeftCancel action: dragRightCancel

Constructor

new MouseInteractionManager()

Members

_dragRight :boolean

A flag for whether we are right-click dragging

Type:
  • boolean

controlIcon :ControlIcon

An optional ControlIcon instance for the object

Type:

dragTime :number

The drag handling time

Type:
  • number

handlers :Object.<function()>

Bound handlers which can be added and removed

Type:
  • Object.<function()>

INTERACTION_STATES :number

Enumerate the states of a mouse interaction workflow. 0: NONE - the object is inactive 1: HOVER - the mouse is hovered over the object 2: CLICKED - the object is clicked 3: DRAG - the object is being dragged 4: DROP - the object is being dropped

Type:
  • number

lcTime :number

The time of the last left-click event

Type:
  • number

options :Object

Interaction options which configure handling workflows

Type:
  • Object

rcTime :number

The time of the last right-click event

Type:
  • number

state :number

The current interaction state

Type:
  • number

states

A reference to the possible interaction states which can be observed

target

Get the target

Methods

activate()

Activate interactivity for the handled object

callback(action, event)

Execute a callback function associated with a certain action in the workflow

Parameters:
Name Type Description
action string

The action being attempted

event Event

The event being handled

can(action, event) → {boolean}

Test whether the current user has permission to perform a step of the workflow

Parameters:
Name Type Description
action string

The action being attempted

event Event

The event being handled

Returns:

Can the action be performed?

Type
boolean

cancel(event)

A public method to cancel a current interaction workflow from this manager.

Parameters:
Name Type Description
event Event

The event that initiates the cancellation