Mouse Class

Module: Input

Mouse instance for sync input the mouse should be updated everytime before.

Automatically calculates the diff of position between frames.

The mouse object provided by scripts is automatically updated by the runtime handler.

Methods

buttonDoubleClicked

(
  • button
)
Boolean

Check if Mouse button was double clicked.

Parameters:

  • button Number

    Button to check status of

Returns:

Boolean:

True if some mouse button was just double clicked

buttonJustPressed

(
  • button
)
Boolean

Check if a mouse button was just pressed.

Parameters:

  • button Number

    Button to check status of

Returns:

Boolean:

True if button was just pressed

buttonJustReleased

(
  • button
)
Boolean

Check if a mouse button was just released.

Parameters:

  • button Number

    Button to check status of

Returns:

Boolean:

True if button was just released

buttonPressed

(
  • button
)
Boolean

Check if mouse button is currently pressed.

Parameters:

  • button Number

    Button to check status of

Returns:

Boolean:

True if button is currently pressed

create

()

Create mouse events.

dispose

()

Dispose mouse events.

insideCanvas

() Boolean

Check if mouse is inside attached canvas (updated async).

Returns:

Boolean:

True if mouse is currently inside the canvas

setCanvas

(
  • canvas
)

Element to be used to calculate coordinates relative to that canvas.

Parameters:

  • canvas Component

    Canvas to be attached to the Mouse instance

setLock

(
  • value
)

Set mouse lock, if true mouse lock will be request, if false the mouse will be released.

Parameters:

  • value Boolean

    If true pointer lock will be requested for the canvas attached to the Mouse instance

update

()

Update mouse buttons state, position, wheel and delta synchronously.

updateKey

(
  • button
  • action
)

Update a mouse button.

Parameters:

  • button Number
  • action Number

updatePosition

(
  • x
  • y
  • xDiff
  • yDiff
)

Update mouse position.

Parameters:

  • x Number
  • y Number
  • xDiff Number
  • yDiff Number

Properties

canvas

Element

Canvas attached to this mouse instance used to calculate position and delta in element space coordinates.

delta

Vector2

Mouse movement (coordinates in window space).

domElement

Element

DOM element where to attach the mouse events.

doubleClicked

Array

Indicates a button of the mouse was double clicked.

events

EventManager

Event manager responsible for updating the raw data variables.

Diferent events are used depending on the host platform.

When the update method is called the raw data is reset.

keys

Array

Array with mouse buttons status.

position

Vector2

Mouse position inside of the window (coordinates in window space).

wheel

Number

Mouse scroll wheel movement.

Attributes

BACK

Number

Back mouse navigation button.

FORWARD

Number

Forward mouse navigation button.

LEFT

Number

Left mouse button.

MIDDLE

Number

Middle mouse button.

RIGHT

Number

Right mouse button.