Class: MouseManager

Phaser.Input.Mouse. MouseManager

The Mouse Manager is a helper class that belongs to the Input Manager.

Its role is to listen for native DOM Mouse Events and then pass them onto the Input Manager for further processing.

You do not need to create this class directly, the Input Manager will create an instance of it automatically.


new MouseManager(inputManager)

Parameters:
Name Type Description
inputManager Phaser.Input.InputManager

A reference to the Input Manager.

Since: 3.0.0
Source: src/input/mouse/MouseManager.js (Line 13)

Members


capture :boolean

If true the DOM mouse events will have event.preventDefault applied to them, if false they will propagate fully.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/input/mouse/MouseManager.js (Line 43)

enabled :boolean

A boolean that controls if the Mouse Manager is enabled or not.
Can be toggled on the fly.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/input/mouse/MouseManager.js (Line 53)

locked :boolean

If the mouse has been pointer locked successfully this will be set to true.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/input/mouse/MouseManager.js (Line 74)

manager :Phaser.Input.InputManager

A reference to the Input Manager.

Type:
Since: 3.0.0
Source: src/input/mouse/MouseManager.js (Line 34)

target :any

The Touch Event target, as defined in the Game Config.
Typically the canvas to which the game is rendering, but can be any interactive DOM element.

Type:
  • any
Since: 3.0.0
Source: src/input/mouse/MouseManager.js (Line 64)

Methods


destroy()

Destroys this Mouse Manager instance.

Since: 3.0.0
Source: src/input/mouse/MouseManager.js (Line 398)

disableContextMenu()

Attempts to disable the context menu from appearing if you right-click on the browser.

Works by listening for the contextmenu event and prevent defaulting it.

Use this if you need to enable right-button mouse support in your game, and the browser
menu keeps getting in the way.

Since: 3.0.0
Source: src/input/mouse/MouseManager.js (Line 118)
Returns:

This Mouse Manager instance.

Type
Phaser.Input.Mouse.MouseManager

onMouseDown(event)

The Mouse Down Event Handler.

Parameters:
Name Type Description
event MouseEvent

The native DOM Mouse Down Event.

Since: 3.10.0
Source: src/input/mouse/MouseManager.js (Line 231)

onMouseMove(event)

The Mouse Move Event Handler.

Parameters:
Name Type Description
event MouseEvent

The native DOM Mouse Move Event.

Since: 3.10.0
Source: src/input/mouse/MouseManager.js (Line 204)

onMouseUp(event)

The Mouse Up Event Handler.

Parameters:
Name Type Description
event MouseEvent

The native DOM Mouse Up Event.

Since: 3.10.0
Source: src/input/mouse/MouseManager.js (Line 258)

pointerLockChange(event)

Internal pointerLockChange handler.

Parameters:
Name Type Description
event MouseEvent

The native event from the browser.

Since: 3.0.0
Source: src/input/mouse/MouseManager.js (Line 167)

releasePointerLock()

If the browser supports pointer lock, this will request that the pointer lock is released. If
the browser successfully enters a locked state, a 'POINTER_LOCK_CHANGE_EVENT' will be
dispatched - from the game's input manager - with an isPointerLocked property.

Since: 3.0.0
Source: src/input/mouse/MouseManager.js (Line 187)

requestPointerLock()

If the browser supports it, you can request that the pointer be locked to the browser window.

This is classically known as 'FPS controls', where the pointer can't leave the browser until
the user presses an exit key.

If the browser successfully enters a locked state, a POINTER_LOCK_CHANGE_EVENT will be dispatched,
from the games Input Manager, with an isPointerLocked property.

It is important to note that pointer lock can only be enabled after an 'engagement gesture',
see: https://w3c.github.io/pointerlock/#dfn-engagement-gesture.

Since: 3.0.0
Source: src/input/mouse/MouseManager.js (Line 142)

startListeners()

Starts the Mouse Event listeners running.
This is called automatically and does not need to be manually invoked.

Since: 3.0.0
Source: src/input/mouse/MouseManager.js (Line 285)

stopListeners()

Stops the Mouse Event listeners.
This is called automatically and does not need to be manually invoked.

Since: 3.0.0
Source: src/input/mouse/MouseManager.js (Line 375)