API Docs for: 1.7.0
Show:

photonui.MouseManager Class

Extends photonui.Base
Module: NonVisual
Parent Module: PhotonUI

Manage advanced mouse events on Widgets or HTMLElements.

wEvents:

  • mouse-event:

    • description: Called for ALL mouse events.
    • callback: function(manager, mstate)
  • mouse-down:

    • description: Mouse button pressed.
    • callback: function(manager, mstate)
  • mouse-up:

    • description: Mouse button released.
    • callback: function(manager, mstate)
  • click:

    • description: Click...
    • callback: function(manager, mstate)
  • double-click:

    • description: Double click...
    • callback: function(manager, mstate)
  • drag-start:

    • description: Start dragging.
    • callback: function(manager, mstate)
  • dragging:

    • description: dragging.
    • callback: function(manager, mstate)
  • drag-end:

    • description: Stop dragging.
    • callback: function(manager, mstate)
  • mouse-move:

    • description: Mouse move on the element.
    • callback: function(manager, mstate)
  • scroll-up:

    • description: Scroll up.
    • callback: function(manager, mstate)
  • scroll-down:

    • description: Scroll down.
    • callback: function(manager, mstate)

mstate:

A snapshot of the mouse state ath the moment when the event occured.

{
    event: <Object>,       // The original js event
    action: <String>,      // The event name (mouse-down/up/move, click, double-click,
                           //    drag-start/end, dragging, scroll-up/down)
    pageX: <Number>,       // X position, relative to page top-left corner.
    pageY: <Number>,       // Y position, relative to page top-left corner.
    x: <Number>,           // X position, relative to the HTML element.
    y: <Number>,           // Y position, relative to the HTML element.
    deltaX: <Number>,      // Delta X (current_x - previous_x)
    deltaY: <Number>,      // Delta Y (current_y - previous_y)
    btnLeft: <Boolean>,    // Current state of the mouse left button.
    btnMiddle: <Boolean>,  // Current state of the mouse middle button.
    btnRight: <Boolean>,   // Current state of the mouse right button.
    button: <String>       // The button that triggered the last event (none, "left", "middle", "right").
}

Constructor

photonui.MouseManager

(
  • element
  • element
  • params
)

Parameters:

Methods

__onDocumentMouseMove

(
  • event
)
private

Used to detect dragging outside the element.

Parameters:

__onDocumentMouseUp

(
  • event
)
private

Used to detect drag-end outside the element.

Parameters:

__onDoubleClick

(
  • event
)
private

Parameters:

__onMouseDown

(
  • event
)
private

Parameters:

__onMouseMove

(
  • event
)
private

Parameters:

__onMouseUp

(
  • event
)
private

Parameters:

__onMouseWheel

(
  • event
)
private

Parameters:

_bindEvent

(
  • id
  • element
  • evName
  • callback
)
private

Inherited from photonui.Base: src/base.js:229

Javascript event binding (for internal use).

Parameters:

  • id String
    An unique id for the event.
  • element DOMElement
    The element on which the event will be bind.
  • evName String
    The event name (e.g. "mousemove", "click",...).
  • callback Function
    The function that will be called when the event occured.

_callCallbacks

(
  • wEvent
  • params
)
private

Inherited from photonui.Base: src/base.js:288

Call all callbacks for the given wEvent. NOTE: the first argument passed to the callback is the current widget. NOTEĀ²: if the thisArg of the callback is null, this will be binded to the current widget.

Parameters:

  • wEvent String
    The widget event.
  • params Array
    Parametters that will be sent to the callbacks.

_dump

() Object private

Take a snapshot of the MouseManager

Returns:

_registerWEvents

(
  • wEvents
)
private

Inherited from photonui.Base: src/base.js:272

Register available wEvent.

Parameters:

_stateMachine

(
  • action
  • event
)
private

Analyze and dispatche wEvents.

Parameters:

  • action String

    The action name (e.g. "mouse-up").

  • event Object

    The js event.

_unbindEvent

(
  • id
)
private

Inherited from photonui.Base: src/base.js:253

Unbind javascript event.

Parameters:

  • id String
    The id of the event.

_updateEvents

() private

Bind events on the HTML Element.

_updateProperties

(
  • properties
)
deprecated private

Inherited from photonui.Base: src/base.js:209

Force the update of the given properties. This method is deprecated. One should use '@photonui-update' abitbol's annotation on concerned properties.

Parameters:

  • properties Array
    The properties to update.

destroy

()

Inherited from photonui.Base: src/base.js:157

Destroy the class.

registerCallback

(
  • id
  • wEvent
  • callback
  • thisArg
)

Inherited from photonui.Base: src/base.js:169

Register a callback for any PhotonUI/Widget event (called wEvent). Callback signature: function (Object(Base/Widget) [, arg1 [, arg2 [, ...]]])

Parameters:

  • id String
    An unique id for the callback.
  • wEvent String
    the PhotonUI/Widget event name.
  • callback Function
    The callback function.
  • thisArg Object
    The value of this (optionnal, default = current widget).

removeCallback

(
  • id
)

Inherited from photonui.Base: src/base.js:193

Remove a registered callback.

Parameters:

  • id String
    The id of the callback.

Properties

__callbacks

Object private

Inherited from photonui.Base: src/base.js:142

Object containing references to registered callbacks.

__event

Object private

Last event object.

Default: {}

__events

Object private

Inherited from photonui.Base: src/base.js:132

Object containing references javascript events binding (for widget internal use).

__mouseDownEvent

Object private

Js event on mouse down.

__prevState

Object private

Previous state.

action

String

The action:

  • "mouse-down"
  • "moues-up"
  • "click"
  • "double-click"
  • "drag-start"
  • "dragging"
  • "drag-end"
  • "scroll-down"
  • "scroll-up"
  • "mouse-move"

btnLeft

Boolean

Current state of the mouse left button.

btnMiddle

Boolean

Current state of the mouse middle button.

btnRight

Boolean

Current state of the mouse right button.

button

String

The button that triggered the last event.

  • none
  • "left"
  • "middle"
  • "right"

data

Object

Inherited from photonui.Base: src/base.js:113

Arbitrary data

Default: {}

deltaX

Number

Delta X (current_x - previous_x).

deltaY

Number

Delta Y (current_y - previous_y).

element

HTMLElement

The HTML Element on which the events are binded.

NOTE: If a photonui.Widget object is assigned to this property, its HTML Element will be automatically assigned to the property instead.

Default: null

pageX

Number

X position, relative to page top-left corner.

Default: 0

pageY

Number

Y position, relative to page top-left corner.

Default: 0

scaleX

Number

Scale all position events by a factor. Use it when the canvas is scaled.

Default: 1

scaleY

Number

Scale all position events by a factor. Use it when the canvas is scaled.

Default: 1

threshold

Number

Minimum distance for triggering a drag-start, and maximum distance to consider a mouse down/up as a click.

Default: 5

translateX

Number

Translate all position events by a scalar. Use it when the canvas is translated.

Default: 0

translateY

Number

Translate all position events by a scalar. Use it when the canvas is translated.

Default: 0

x

Number

X position, relative to the HTML element.

y

Number

Y position, relative to the HTML element.