API Docs for: 1.4.0
Show:

Kiwi.Input.Mouse Class

Defined in: src\input\Mouse.ts:10
Module: Input
Parent Module: Kiwi

Handles the dispatching/management of Mouse Events on a game. When this class is instantiated a MouseCursor object is also created (on this object) which holds the information that is unique to the mouse cursor, although majority of that information is still accessible inside this object.

Constructor

Kiwi.Input.Mouse

(
  • game
)
Kiwi.Input.Mouse

Parameters:

  • game Kiwi.Game

    The game that this mouse manager belongs to.

Returns:

Methods

boot

() public

This method is executed when the DOM has finished loading and thus the MouseManager can start listening for events.

justPressed

(
  • [duration=200]
)
Boolean public

Returns a boolean indicating if the mouse was 'justPressed' within a certain timeframe. The default timeframe is 200 milliseconds.

Parameters:

  • [duration=200] Number optional

    The timeframe that it could have occured in.

Returns:

Boolean:

justReleased

(
  • [duration=200]
)
Boolean public

Returns a boolean indicating if the mouse was 'justReleased' within a certain timeframe. The default timeframe is 200 milliseconds.

Parameters:

  • [duration=200] Number optional

    The timeframe that it could have occured in..

Returns:

Boolean:

objType

() String public

The type of object that this is.

Returns:

String:

"Mouse"

onContextMenu

(
  • event
)
private

Defined in src\input\Mouse.ts:439

Available since 1.3.0

Fired when the context menu event is fired. Used to prevent the context menu from appearing when the 'preventContextMenu' property is set to true.

This event is currently only used when targetting browsers and will not fire for CocoonJS.

Parameters:

  • event Object

onMouseDown

(
  • event.
)
private

Method that gets fired when the mouse is pressed on the stage.

Parameters:

  • event. MouseEvent

onMouseMove

(
  • event.
)
private

Method that gets fired when the mouse moves anywhere on the stage.

Parameters:

  • event. MouseEvent

onMouseUp

(
  • event.
)
private

Method that gets fired when the mouse is released on the stage.

Parameters:

  • event. MouseEvent

onMouseWheel

(
  • event.
)
private

Method that gets fired when the mousewheel is moved.

Parameters:

  • event. MouseEvent

reset

() public

Runs the Reset method on the MouseCursor.

start

() public

Start the mouse event listeners on the game. Automatically called by the boot.

stop

() public

Stops the mouse event listeners from working. Useful if you no longer want the mouse to 'work'/be listened to.

update

() public

The update loop for the cursor.

Properties

_cursor

Kiwi.Input.MouseCursor private

The MouseCursor that is on the stage. This contains the coordinates and information about the cursor.

_domElement

HTMLDivElement private

The HTMLElement that is being used to apply the mouse events to.

_game

Kiwi.Game private

The game that this mouse manager belongs to.

_onContextMenuBind

Function private

Defined in src\input\Mouse.ts:499

Available since 1.3.0

The binding of the 'onContextMenu' method.

_onMouseDownBind

Function private

Defined in src\input\Mouse.ts:459

Available since 1.3.0

The binding of the 'onMouseDown' method.

_onMouseMoveBind

Function private

Defined in src\input\Mouse.ts:469

Available since 1.3.0

The binding of the 'onMouseMove' method.

_onMouseUpBind

Function private

Defined in src\input\Mouse.ts:479

Available since 1.3.0

The binding of the 'onMouseUp' method.

altKey

Boolean public

Indicates if the alt key is down.

Default: false

button

Number public

Returns a number indicating the button that was used. This can be used with the STATIC button properties.

ctrlKey

Boolean public

Indicates if the ctrl key is down.

Default: false

cursor

Kiwi.Input.MouseCursor private

Returns the MouseCursor that is being used on the stage. This is READ ONLY.

duration

Number public

Gets the duration in Milliseconds that the mouse cursor has either been up or down for.

isDown

Boolean public

Indicates whether or not the cursor is currently down. This is READ ONLY.

Default: false

isUp

Boolean public

Indicates whether or not the cursor is currently up. This is READ ONLY.

Default: true

LEFT_BUTTON

Number public final static

The numeric value for the LEFT button.

Default: 0

MIDDLE_BUTTON

Number public final static

The numeric value for the MIDDLE button.

Default: 1

onContext

Kiwi.Signal public

Defined in src\input\Mouse.ts:412

Available since 1.3.0

Dispatches events when the context menu is fired.

Functions fired from this Signal will have the a single argument being the event of the 'contextmenu' gives.

onDown

Kiwi.Signal public

A Signal that dispatches events when the mouse is pressed down on the stage.

onMouseWheel

Function private

Defined in src\input\Mouse.ts:489

Available since 1.3.0

The binding of the 'onMouseWheel' method.

onUp

Kiwi.Signal public

A Signal that dispatches events when the mouse is released from being down on the stage.

onWheel

Kiwi.Signal public

A Signal that dispatches events mouse wheel moves.

preventContextMenu

Boolean public

Defined in src\input\Mouse.ts:425

Available since 1.3.0

Determines whether or not the context menu should appear when the user 'right clicks' on the stage.

Only has an effect on games targetting browsers.

Default: false

RIGHT_BUTTON

Number public final static

The numeric value for the RIGHT button.

Default: 2

shiftKey

Boolean public

Indicates if the shift key is down.

Default: false

wheelDeltaX

Number public

Gets the wheelDeltaX coordinate of the mouse cursors wheel.

wheelDeltaY

Number public

Gets the wheelDeltaY coordinate of the mouse cursors wheel.

x

Number public

Gets the x coordinate of the mouse cursor.

y

Number public

Gets the y coordinate of the mouse cursor.