Class: MouseBox

html.MouseBox

Class representing a box that accepts input from mouse, touch screen, or a pen. Multitouch input is supported.

new html.MouseBox ()

Properties:
Name Type Description
containsMouse bool

[readonly] Whether the mouse pointer is over the box.

hoverDelay number

(default: 500) The hover delay in ms.

hovered bool

[readonly] Whether the mouse pointer is hovering over the box. This is similar to containsMouse but has a delay.

pressed bool

[readonly] Whether the box is currently pressed.

touchPoints number

[readonly] The current amount of touch points.

Fires:
  • event:doubleClick
  • event:drag
  • event:dragEnd
  • event:click
  • event:mouseDown
  • event:mouseMove
  • event:mouseOut
  • event:mouseOver
  • event:mouseUp
  • event:pointerDown
  • event:pointerEnter
  • event:pointerLeave
  • event:pointerMove
  • event:pointerOut
  • event:pointerUp
  • event:wheel

Extends

Methods

touchPoint (n)object

Returns the n-th touch point.

Name Type Description
n number

The index of the touch point to return.

Returns:
Type Description
object The touch point, or null if the touch point does not exist.

Type Definitions

html.MouseBox.DragEvent

A drag event. This is not related to drag-and-drop functionality.

The drag only starts if the accepted property is set to true.

Properties:
Name Type Description
accepted bool

(default: false) Set to true to accept the event and initiate the drag.

buttons number

[readonly] The buttons pressed.

deltaX number

[readonly] The drag amount in X direction.

deltaY number

[readonly] The drag amount in Y direction.

original Event

[readonly] The original HTML pointer event.

html.MouseBox.PointerEvent

A pointer event.

Properties:
Name Type Description
accepted bool

(default: false) Set to true to accept the event and prevent it from bubbling up.

buttons number

[readonly] The buttons pressed as a bitmask with left = 1, right = 2, middle = 4.

directTarget bool

[readonly] true if this event was emitted by the direct target instead of having bubbled up.

original Event

[readonly] The original HTML pointer event.

pointerId number

[readonly] The ID of the pointer.

pointerType string

[readonly] The type of pointer. One of mouse|pen|touch

pressure number

[readonly] The pressure (typically of a pen) applied as number in the range of 0 and 1.

tiltX number

[readonly] The tilt of the pen in X direction.

tiltY number

[readonly] The tilt of the pen in Y direction.

x number

[readonly] The X position of the pointer within the MouseBox.

y number

[readonly] The Y position of the pointer within the MouseBox.

html.MouseBox.WheelEvent

A wheel event.

Properties:
Name Type Description
accepted bool

(default: false) Set to true to accept the event and prevent it from bubbling up.

deltaX number

[readonly] The scroll amount in X direction.

deltaY number

[readonly] The scroll amount in Y direction.

deltaZ number

[readonly] The scroll amount in Z direction.

original Event

[readonly] The original HTML wheel event.

x number

[readonly] The X position of the pointer within the MouseBox.

y number

[readonly] The Y position of the pointer within the MouseBox.

Events

html.MouseBox.event:click

Is triggered when a mouse button was clicked.

Name Type Description
event html.MouseBox.PointerEvent

The event object.

html.MouseBox.event:contextMenu

Is triggered when the context menu is requested (usually upon clicking the right mouse button).

Name Type Description
event html.MouseBox.PointerEvent

The event object.

html.MouseBox.event:doubleClick

Is triggered when a mouse button was double-clicked.

Name Type Description
event html.MouseBox.PointerEvent

The event object.

html.MouseBox.event:drag

Is triggered when the item is being dragged.

Name Type Description
event html.MouseBox.DragEvent

The event object.

html.MouseBox.event:dragEnd

Is triggered when the item is finished being dragged.

Name Type Description
event html.MouseBox.DragEvent

The event object.

html.MouseBox.event:pointerDown

Is triggered when a pointer device button is pressed.

Name Type Description
event html.MouseBox.PointerEvent

The event object.

html.MouseBox.event:pointerEnter

Is triggered when a pointer device enters the item.

Name Type Description
event html.MouseBox.PointerEvent

The event object.

html.MouseBox.event:pointerLeave

Is triggered when a pointer device gets out of reach, e.g. a pen is lifted.

Name Type Description
event object

The event object.

html.MouseBox.event:pointerMove

Is triggered when a pointer device is being moved.

Name Type Description
event html.MouseBox.PointerEvent

The event object.

html.MouseBox.event:pointerOut

Is triggered when a pointer device leaves the item.

Name Type Description
event html.MouseBox.PointerEvent

The event object.

html.MouseBox.event:pointerUp

Is triggered when a pointer device button is released.

Name Type Description
event html.MouseBox.PointerEvent

The event object.

html.MouseBox.event:wheel

Is triggered when the mouse wheel is rolled.

Name Type Description
event html.MouseBox.WheelEvent

The event object.