natiny.input.set_mouse_capture
natiny.input.set_mouse_capture(enabled)
Enables or disables mouse capture. While captured, the cursor is hidden and mouse movement continues past the window edges.
Parameters
| Name | Type | Description |
|---|---|---|
enabled |
boolean |
true to capture the mouse, false to release it |
Example
if natiny.input.get_mouse_button_pressed(natiny.input.MOUSE_BUTTON_LEFT) then
natiny.input.set_mouse_capture(true)
end
Notes
- A window must exist before this function is called. Otherwise it does nothing.
- Escape releases the mouse. In a browser, changing tabs can also release it;
use
natiny.input.get_mouse_capturedto read the state. - In a browser, enabling capture may be deferred until the next user gesture, and a refused request is retried on the next click. A browser refuses one for about a second after Escape released the last.
- Mouse movement is
0on the frame capture changes and on the following frame.