Class: MouseHandler
input/mouse.MouseHandler
Handles mouse events for an {@link HTMLElement}.
Constructors
constructor
โข new MouseHandler(element
)
Parameters
Name | Type |
---|---|
element | HTMLElement |
Defined in
src/input/mouse.ts:32
Properties
buttons
โข Private
buttons: Object
= {}
Index signature
โช [index: number
]: boolean
Defined in
src/input/mouse.ts:29
element
โข Readonly
element: HTMLElement
Defined in
src/input/mouse.ts:22
listeners
โข Private
listeners: Object
= {}
Index signature
โช [index: number
]: MouseCallback
[]
Defined in
src/input/mouse.ts:30
position
โข Private
position: vec2
The mouse's current position within the element.
Defined in
src/input/mouse.ts:27
Methods
addListener
โธ addListener(button
, cb
): void
Attaches a listener to a given mouse button that is called whenever the state of the button changes.
Parameters
Name | Type | Description |
---|---|---|
button | Mouse | The Mouse button to attach the listener to |
cb | MouseCallback | The callback to execute on a mousedown/mouseup event |
Returns
void
Defined in
src/input/mouse.ts:87
addListeners
โธ Private
addListeners(): void
Returns
void
Defined in
src/input/mouse.ts:37
getMousePos
โธ getMousePos(): vec2
Gets the current mouse position within the element.
If the mouse has not yet entered the element then the position will be [0, 0].
Returns
vec2
The mouse position in pixels as a {@link vec2};
Defined in
src/input/mouse.ts:67
isPressed
โธ isPressed(button?
): boolean
Determines wether the given mouse button is pressed.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
button | Mouse | Mouse.LEFT | The Mouse button to check |
Returns
boolean
Wether the given button is pressed or not
Defined in
src/input/mouse.ts:77
removeListener
โธ removeListener(button
, cb
): void
Removes a listener from a given mouse button.
Parameters
Name | Type | Description |
---|---|---|
button | Mouse | The Mouse button the listener is attached to |
cb | MouseCallback | The attached listener |
Returns
void
Defined in
src/input/mouse.ts:101