natiny.view.set_focus

Lua
natiny.view.set_focus([view])

Sets the program-wide input focus to one view. A press on a pickable view sets the focus before its natiny.view.HOOK_MOUSE_DOWN callback runs.

Parameters

Name Type Default Description
view number nil Focusable view handle; omit or pass nil to clear, while 0 raises an error and a destroyed or non-focusable handle clears

Example

Lua
-- Give a newly opened form an initial focus target.
natiny.view.set_focus(first_field)

Notes

  • Destroying or hiding the focused view or one of its ancestors clears the focus. Making the focused view or one of its ancestors non-focusable also clears it.
  • While a view hook runs, input event and state getters return neutral values unless the focus is that view or one of its descendants. Pointer position and hover remain available.