add(state, custom_id) | template<FocusableState T> FocusManager& add(T& state, Id custom_id = Id::none()) | Registers state (using custom_id or Id(&state) combined with active scopes) and auto-wires handle_mouse and handle_paste if supported. | custom_id = Id::none() |
add(id, on_key, on_mouse) | FocusManager& add(Id id, std::function<bool(const KeyEvent&)> on_key = nullptr, std::function<bool(const MouseEvent&)> on_mouse = nullptr) | Registers a stateless target by Id. If on_mouse == nullptr and on_key != nullptr, left clicks synthesize Key::Enter to on_key. | nullptr, nullptr |
register_target(target) | void register_target(FocusTarget target) | Inserts or updates target in m_targets; focuses index 0 on first target or focuses immediately if registered inside an active modal scope. | None |
remove(id) / remove(state) | bool remove(Id id) / bool remove(const T& state) | Removes target from m_targets and clamps m_active_index. | None |
set_visible() / is_visible() | FocusManager& set_visible(Id id, bool visible) / bool is_visible(Id id) const | Sets or queries target visibility (false skips target in next()/prev()). | true |
set_enabled() / is_enabled() | FocusManager& set_enabled(Id id, bool enabled) / bool is_enabled(Id id) const | Sets or queries target enabled state (false skips target in next()/prev()). | true |
has_geometry() | bool has_geometry() const noexcept | Returns true if at least one target has valid non-zero bounds. | false before sync_geometry |
next() / prev() | bool next() / bool prev() | Cycles forward (Tab) or backward (BackTab) through focusable targets in the active modal scope. | None |
focus(...) / focus_id(...) | bool focus(size_t index) / bool focus_id(Id id) / bool focus(Id id) / bool focus(const T& state) | Focuses the specified target if it belongs to the active modal scope and can_focus returns true. | None |
sync_geometry(frame) | void sync_geometry(const Frame& frame) | Copies frame.bounds_of(target.id) into each target and calls next() if the active target is no longer focusable on screen. | None |
move(dir) / move_up() / down() / left() / right() | bool move(Direction dir) | Moves focus in 2D to the target in the active modal scope minimizing primary_dist + 2 * secondary_dist. | None |
is_focused(...) | bool is_focused(Id id) const / bool is_focused(const T& state) const | Returns true if id or state is the currently focused target. | None |
current_index() / current_id() | size_t current_index() const noexcept / Id current_id() const noexcept | Returns active index or active Id (Id::none() if empty). | 0 / Id::none() |
size() / empty() / clear() | size_t size() const noexcept / bool empty() const noexcept / void clear() | Queries target count or clears all targets, scopes, and saved focus stack. | None |
handle_key(key) | bool handle_key(const KeyEvent& key) | Dispatches key through interceptor, Tab/BackTab, AltArrows, active target, and SpatialArrows. | None |
handle_paste(text) | bool handle_paste(const std::string& text) | Routes text to the active target’s handle_paste closure. | None |
navigation_policy(...) | FocusManager& navigation_policy(FocusNavPolicy policy) noexcept / FocusNavPolicy navigation_policy() const noexcept | Sets or gets the active FocusNavPolicy. | FocusNavPolicy::TabOnly |
enable_spatial_arrows() | FocusManager& enable_spatial_arrows(bool enable = true) noexcept | Sets policy to SpatialArrows when true or TabOnly when false. | enable = true |
interceptor() / can_focus() / on_focus_change() | Hook setters | Registers FocusKeyInterceptor, FocusChangeValidator, or FocusChangeObserver. | nullptr |
handle_mouse() / handle_mouse_click() | bool handle_mouse(const MouseEvent& mouse, const Frame& frame) / bool handle_mouse_click(int row, int col, const Frame& frame) | Hit-tests (row, col) in frame, shifts focus on left press, routes mouse wheel/press to target, and shields background targets during a modal scope. | None |
scope(id) / modal_scope(id) | IdScope scope(Id scope_id) / IdScope modal_scope(Id scope_id) | Returns an RAII IdScope with ScopeMode::Normal or ScopeMode::Modal. | None |
push_scope() / pop_scope() | void push_scope(Id scope_id, ScopeMode mode = ScopeMode::Normal) / void pop_scope() | Manually pushes or pops a scope entry (Modal pop erases modal targets and restores saved focus). | mode = ScopeMode::Normal |
scoped_id() / id() / active_modal_scope() | Id scoped_id(Id base_id) const / Id id(Id base_id) const / Id id(const T& state) const / Id active_modal_scope() const | Computes scope-prefixed Id or returns the innermost active modal scope Id. | Id::none() |