natiny_input_set_mouse_capture

C
void natiny_input_set_mouse_capture(bool 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 bool true to capture the mouse, false to release it

Example

C
if (natiny_input_get_mouse_button_pressed(NATINY_INPUT_MOUSE_BUTTON_LEFT))
    natiny_input_set_mouse_capture(true);

Notes

  • Escape releases the mouse. In a browser, changing tabs can also release it; use natiny_input_get_mouse_captured to 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.