natiny.input.set_cursor

Lua
natiny.input.set_cursor(cursor)

Sets the persistent, program-wide mouse cursor shape. The setting applies to every window, including windows created after the call.

Parameters

Name Type Description
cursor integer Cursor constant below; converted to uint32_t, after which values above 9 print a diagnostic and leave the setting unchanged

Constants

Name Value Description
natiny.input.CURSOR_ARROW 0 Ordinary pointer and the initial shape
natiny.input.CURSOR_TEXT 1 I-beam for text input
natiny.input.CURSOR_CROSSHAIR 2 Crosshair for aiming or precise selection
natiny.input.CURSOR_HAND 3 Pointing hand for an interactive element
natiny.input.CURSOR_RESIZE_EW 4 Horizontal resize arrow
natiny.input.CURSOR_RESIZE_NS 5 Vertical resize arrow
natiny.input.CURSOR_RESIZE_NWSE 6 Diagonal resize arrow from top-left to bottom-right
natiny.input.CURSOR_RESIZE_NESW 7 Diagonal resize arrow from top-right to bottom-left
natiny.input.CURSOR_MOVE 8 Four-way move arrow
natiny.input.CURSOR_FORBIDDEN 9 Indicates that an action is not allowed

Example

Lua
-- Reset the shape before hovered elements override it.
natiny.input.set_cursor(natiny.input.CURSOR_ARROW)

if natiny.view.get_hovered(button) then
    natiny.input.set_cursor(natiny.input.CURSOR_HAND)
end

Notes

  • On platforms without a visible cursor, this records the shape without displaying it. natiny.input.get_cursor still returns the recorded shape.
  • Mouse capture hides the cursor without changing its shape. The cursor uses the recorded shape again when capture is released. See natiny.input.set_mouse_capture.