Options
All
  • Public
  • Public/Protected
  • All
Menu

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: dragRightStart action: dragLeftMove action: dragRightMove _handleMouseUp action: dragLeftDrop action: dragRightDrop _handleDragCancel action: dragLeftCancel action: dragRightCancel

Hierarchy

  • MouseInteractionManager

Index

Constructors

  • new MouseInteractionManager(object: any, layer: any, permissions?: {}, callbacks?: {}, options?: {}): MouseInteractionManager
  • Parameters

    • object: any
    • layer: any
    • permissions: {} = {}
      • callbacks: {} = {}
        • options: {} = {}

          Returns MouseInteractionManager

        Properties

        object: any
        layer: any
        permissions: {}

        Type declaration

          callbacks: {}

          Type declaration

            options: { target: DisplayObject; dragResistance: number }

            Interaction options which configure handling workflows

            Type declaration

            • target: DisplayObject
            • dragResistance: number
            state: number

            The current interaction state

            interactionData: any

            Bound interaction data object to populate with custom data.

            dragTime: number

            The drag handling time

            lcTime: number

            The time of the last left-click event

            rcTime: number

            The time of the last right-click event

            _dragRight: boolean

            A flag for whether we are right-click dragging

            controlIcon: ControlIcon

            An optional ControlIcon instance for the object

            viewId: any
            #handlers: any = {}

            Bound handlers which can be added and removed

            INTERACTION_STATES: { NONE: number; HOVER: number; CLICKED: number; DRAG: number; DROP: 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 declaration

            • NONE: number
            • HOVER: number
            • CLICKED: number
            • DRAG: number
            • DROP: number
            LONG_PRESS_DURATION_MS: number = 500

            The number of milliseconds of mouse click depression to consider it a long press.

            longPressTimeout: number = null

            Global timeout for the long-press event.

            #HANDLER_OUTCOME: { SKIPPED: number; DISALLOWED: number; REFUSED: number; ACCEPTED: number } = ...

            Enumerate the states of handle outcome. -2: SKIPPED - the handler has been skipped by previous logic -1: DISALLOWED - the handler has dissallowed further process 1: REFUSED - the handler callback has been processed and is refusing further process 2: ACCEPTED - the handler callback has been processed and is accepting further process

            Type declaration

            • SKIPPED: number
            • DISALLOWED: number
            • REFUSED: number
            • ACCEPTED: number

            Accessors

            • get target(): DisplayObject
            • Get the target.

              Returns DisplayObject

            • get isDragging(): boolean
            • Is this mouse manager in a dragging state?

              Returns boolean

            • get states(): Object
            • A reference to the possible interaction states which can be observed

              Returns Object

            • get handlerOutcomes(): Object
            • A reference to the possible interaction states which can be observed

              Returns Object

            Methods

            • can(action: string, event: any): boolean
            • Test whether the current user has permission to perform a step of the workflow

              Parameters

              • action: string

                The action being attempted

              • event: any

                The event being handled

              Returns boolean

              Can the action be performed?

            • callback(action: string, event: any, ...args: any[]): boolean
            • Execute a callback function associated with a certain action in the workflow

              Parameters

              • action: string

                The action being attempted

              • event: any

                The event being handled

              • Rest ...args: any[]

                Additional callback arguments.

              Returns boolean

              A boolean which may indicate that the event was handled by the callback. Events which do not specify a callback are assumed to have been handled as no-op.

            • handleEvent(event: FederatedEvent): boolean
            • A public method to handle directly an event into this manager, according to its type. Note: drag events are not handled.

              Parameters

              • event: FederatedEvent

              Returns boolean

              Has the event been processed?

            • cancel(event: FederatedEvent): void
            • A public method to cancel a current interaction workflow from this manager.

              Parameters

              • event: FederatedEvent

                The event that initiates the cancellation

              Returns void

            • reset([options]?: { interactionData: boolean; state: boolean }): void
            • Reset the mouse manager.

              Parameters

              • [options]: { interactionData: boolean; state: boolean } = {}
                • interactionData: boolean
                • state: boolean

              Returns void

            • #activateHoverEvents(): void
            • Activate a set of listeners which handle hover events on the target object

              Returns void

            • #activateClickEvents(): void
            • Activate a new set of listeners for click events on the target object.

              Returns void

            • #deactivateClickEvents(): void
            • Deactivate event listeners for click events on the target object.

              Returns void

            • #activateDragEvents(): void
            • Activate events required for handling a drag-and-drop workflow

              Returns void

            • #deactivateDragEvents(silent: boolean): void
            • Deactivate events required for handling drag-and-drop workflow.

              Parameters

              • silent: boolean

              Returns void

            • #handleMouseOver(event: FederatedEvent): void
            • Handle mouse-over events which activate downstream listeners and do not stop propagation.

              Parameters

              • event: FederatedEvent

              Returns void

            • #handleMouseOut(event: FederatedEvent): void
            • Handle mouse-out events which terminate hover workflows and do not stop propagation.

              Parameters

              • event: FederatedEvent

              Returns void

            • #handleMouseDown(event: FederatedEvent): void
            • Handle mouse-down events which activate downstream listeners. Stop further propagation only if the event is allowed by either single or double-click.

              Parameters

              • event: FederatedEvent

              Returns void

            • #handleClickLeft(event: FederatedEvent): void
            • Handle mouse-down which trigger a single left-click workflow.

              Parameters

              • event: FederatedEvent

              Returns void

            • #handleClickLeft2(event: FederatedEvent): void
            • Handle mouse-down which trigger a single left-click workflow.

              Parameters

              • event: FederatedEvent

              Returns void

            • #handleLongPress(event: FederatedEvent, origin: Point): void
            • Handle a long mouse depression to trigger a long-press workflow.

              Parameters

              • event: FederatedEvent

                The mousedown event.

              • origin: Point

                The original canvas co-ordinates of the mouse click

              Returns void

            • #handleRightDown(event: FederatedEvent): void
            • Handle right-click mouse-down events. Stop further propagation only if the event is allowed by either single or double-click.

              Parameters

              • event: FederatedEvent

              Returns void

            • #handleClickRight(event: FederatedEvent): void
            • Handle single right-click actions.

              Parameters

              • event: FederatedEvent

              Returns void

            • #handleClickRight2(event: FederatedEvent): void
            • Handle double right-click actions.

              Parameters

              • event: FederatedEvent

              Returns void

            • #handleMouseMove(event: FederatedEvent): void
            • Handle mouse movement during a drag workflow

              Parameters

              • event: FederatedEvent

              Returns void

            • #handleDragStart(event: FederatedEvent): void
            • Handle the beginning of a new drag start workflow, moving all controlled objects on the layer

              Parameters

              • event: FederatedEvent

              Returns void

            • #handleDragMove(event: FederatedEvent): void
            • Handle the continuation of a drag workflow, moving all controlled objects on the layer

              Parameters

              • event: FederatedEvent

              Returns void

            • #handleMouseUp(event: FederatedEvent): void
            • Handle mouse up events which may optionally conclude a drag workflow

              Parameters

              • event: FederatedEvent

              Returns void

            • #handleDragDrop(event: FederatedEvent): void
            • Handle the conclusion of a drag workflow, placing all dragged objects back on the layer

              Parameters

              • event: FederatedEvent

              Returns void

            • #handleDragCancel(event: FederatedEvent): void
            • Handle the cancellation of a drag workflow, resetting back to the original state

              Parameters

              • event: FederatedEvent

              Returns void

            • #debug(action: string, event: any, outcome?: number): void
            • Display a debug message in the console (if mouse interaction debug is activated).

              Parameters

              • action: string

                Which action to display?

              • event: any

                Which event to display?

              • outcome: number = ...

              Returns void

            • #assignInteractionData(event: FederatedEvent): void
            • Assign the interaction data to the event.

              Parameters

              • event: FederatedEvent

              Returns void