Constructor
new MouseHandler(parentHandler, condition)
Create a new mouse input handler.
Parameters:
Name | Type | Description |
---|---|---|
parentHandler | EventHandler | | Parent event handler or layer |
condition | function | Function for checking whether events should run |
Extends
Members
pos
Get the current position of the mouse.
Methods
(protected) _doDown(key, args)
Fire a specific key if there are events listening for it.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
key | any | Key to fire | |
args | any | null | Optional arguments to pass into function |
- Overrides
(protected) _doPress(key, args)
Fire a specific key if there are events listening for it.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
key | any | Key to fire | |
args | any | null | Optional arguments to pass into function |
- Overrides
(protected) _doRelease(key, args)
Fire a specific key if there are events listening for it.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
key | any | Key to fire | |
args | any | null | Optional arguments to pass into function |
- Overrides
capture() → {boolean}
Capture and "claim" the mouse
Returns:
Whether capture was successful
- Type:
- boolean
destructor()
Handle deletion of the handler and its input listeners.
- Overrides
gameFocused() → {boolean}
Check if the game is in focus (user is not focused on input).
- Overrides
Returns:
Whether the game is focused
- Type:
- boolean
isCaptured() → {boolean}
Check if the mouse is currently captured.
Returns:
Whether the mouse is captured
- Type:
- boolean
isDown(key) → {boolean}
Check if a key is currently being held down.
Parameters:
Name | Type | Description |
---|---|---|
key | any | Key to check for |
- Overrides
Returns:
Whether key is being held down
- Type:
- boolean
isInWindow() → {boolean}
Check if the mouse is currently within the canvas.
Returns:
Whether mouse is within canvas
- Type:
- boolean
onMove(func)
Add a function to listen for mouse movement.
Parameters:
Name | Type | Description |
---|---|---|
func | function | Function to run upon mouse movement |
onPress(key, func)
Add an event to listen for a specific key press. Will fire once.
Parameters:
Name | Type | Description |
---|---|---|
key | any | | Key(s) to listen for |
func | function | Function to run upon firing |
- Overrides
onRelease(key, func)
Add an event to listen for a specific key release. Will fire once.
Parameters:
Name | Type | Description |
---|---|---|
key | any | | Key(s) to listen for |
func | function | Function to run upon firing |
- Overrides
onScroll(func)
Add a function to listen for the mouse scroll wheel.
Parameters:
Name | Type | Description |
---|---|---|
func | function | Function to run upon scrolling |
release()
Release the mouse.
setCursor(cursor)
Set the mouse cursor ("default" by default).
Parameters:
Name | Type | Default | Description |
---|---|---|---|
cursor | string | default | New cursor |
whileDown(key, func)
Add an event to fire while a key is pressed down. Fires continuously.
Parameters:
Name | Type | Description |
---|---|---|
key | any | | Key(s) to listen for |
func | function | Function to run upon firing |
- Overrides