photonui.MouseManager Class
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:
-
element
photonui.WidgetAny PhotonUI Widget (optional).
-
element
HTMLElementAny HTML element (optional).
-
params
Objectadditional params (optional).
Item Index
Methods
Methods
__onDocumentMouseMove
-
event
Used to detect dragging outside the element.
Parameters:
-
event
Object
__onDocumentMouseUp
-
event
Used to detect drag-end outside the element.
Parameters:
-
event
Object
_bindEvent
-
id
-
element
-
evName
-
callback
-
[options]
Parameters:
_callCallbacks
-
wEvent
-
params
_stateMachine
-
action
-
event
Analyze and dispatche wEvents.
_updateEvents
()
private
Bind events on the HTML Element.
_updateProperties
-
properties
Parameters:
-
properties
ArrayThe properties to update.
destroy
()
registerCallback
-
id
-
wEvent
-
callback
-
thisArg
Properties
__dragStartButton
String
private
The button that triggered the drag start event
- null
- "left"
- "middle"
- "right"
Default: null
__events
Object
private
action
String
The action:
- "mouse-down"
- "moues-up"
- "click"
- "double-click"
- "drag-start"
- "dragging"
- "drag-end"
- "scroll-down"
- "scroll-up"
- "mouse-move"
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
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