Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Rikitav/Terminality/llms.txt
Use this file to discover all available pages before exploring further.
FocusManager is the central authority for keyboard focus in a Terminality application. It maintains an ordered focus stack — the chain of nodes from the root container down to the currently focused leaf — and exposes methods to set focus explicitly, move it in a direction, and remove it when a node is destroyed or hidden. The engine calls MoveNext automatically in response to Tab and arrow-key input, so most applications only need to listen to FocusChanged or call SetFocused to seed the initial focus.
Class: FocusManager
Access the singleton with FocusManager::Current(). The instance is owned by VisualTree and is safe to call from event handlers, hotkey callbacks, and TickEvent subscriptions.
FocusManager::Current() delegates to VisualTree::Current().GetFocusManager(). It returns the FocusManager for the topmost active layer.Current
FocusManager for the topmost active layer. Internally delegates to VisualTree::Current().GetFocusManager().
GetFocused
nullptr when nothing is focused.
The currently focused node, or
nullptr if the focus stack is empty.SetFocused
node. The call is a no-op — and returns false — if node is nullptr or not focusable (i.e. IsFocusable() returns false). If node is a child of the current focus, it is pushed onto the stack; otherwise the stack is cleared and rebuilt from the root. On success, FocusChanged is emitted and OnGotFocus is called on the new node.
The node to focus. Must have
IsFocusable() returning true.true if focus was successfully transferred to node; false otherwise.MoveNext
MoveFocusNext. Nodes that cannot handle the movement are popped and their OnLostFocus is called. Returns true if any node successfully moved focus.
The direction to move focus. See Direction enum below.
Active modifier keys at the time of the key event. Used by container nodes to distinguish Tab from Shift+Tab.
true if focus moved; false if no node in the stack could handle the direction.ClearFocus
node and all nodes above it from the focus stack, calling OnLostFocus on each removed node. If the top of the stack changes, FocusChanged is emitted with the new top (or nullptr if the stack becomes empty).
The node to remove from the focus stack. If not found in the stack, the call is a no-op.
FocusChanged event
nullptr), and the second argument is the newly focused node (may be nullptr when focus is fully cleared).
Direction enum
Defined interminality:Focus. Passed to MoveNext and forwarded to each container’s MoveFocusNext implementation.
| Enumerator | Keyboard gesture | Description |
|---|---|---|
Up | Up arrow | Move focus to a node above |
Down | Down arrow | Move focus to a node below |
Left | Left arrow | Move focus to a node to the left |
Right | Right arrow | Move focus to a node to the right |
Next | Tab | Move focus to the next tab stop |
Previous | Shift + Tab | Move focus to the previous tab stop |
Tab-order navigation
Terminality builds Tab order automatically from the visual tree. When you callMoveNext(Direction::Next), the engine walks the focus stack and calls MoveFocusNext on the innermost container that knows how to cycle its children. You configure participation through properties on ControlBase:
SetFocusable(bool)— whether a control can receive focus at all. Defaults totrue; setfalseon purely decorative controls that should never receive input.SetTabStop(bool)— whether Tab navigation will land on this control. Containers are typically not tab stops even if focusable.SetTabIndex(int)— override the default document-order position in the Tab cycle. Lower values are visited first.
Listening to focus changes
Subscribe toFocusChanged to update visual state or run side-effects when focus moves between controls:
RenderOverride, use the inherited focused_ field to choose colors without additional subscriptions:
Related
ControlBase—SetFocusable,SetTabStop,SetTabIndex,IsFocusableVisualTree— owns theFocusManagerinstanceDispatchTimer— per-frame callbacks that run safely outside the render pass