natiny.view.get_focused

Lua
natiny.view.get_focused(view) -> focused

Returns whether view itself holds the focus. Use natiny.view.get_focus_within to include descendants.

Parameters

Name Type Description
view number View handle

Returns

Type Description
boolean true only when view is the focused view

Example

Lua
natiny.view.set_hook(field, natiny.view.HOOK_DRAW, function(self)
    if natiny.view.get_focused(self) then
        draw_caret()
    end
end)