Documentation
¶
Index ¶
- type FocusManager
- func (fm *FocusManager) AllActiveKeyBindings() []key.Binding
- func (fm *FocusManager) CanFocusTo(leaf widget.Leaf) bool
- func (fm *FocusManager) ChangeFocusTo(leaf widget.Leaf) (bool, tea.Cmd)
- func (fm *FocusManager) FocusByID(id string) (bool, tea.Cmd)
- func (fm *FocusManager) FocusFirst() tea.Cmd
- func (fm *FocusManager) FocusedKeyBindings() []key.Binding
- func (fm *FocusManager) FocusedLeaf() widget.Leaf
- func (fm *FocusManager) HitTest(x, y int) widget.Leaf
- func (fm *FocusManager) IsFocusChangingEvent(msg tea.MouseMsg) bool
- func (fm *FocusManager) Leaves() []widget.Leaf
- func (fm *FocusManager) Next() tea.Cmd
- func (fm *FocusManager) Prev() tea.Cmd
- func (fm *FocusManager) ResolveKeyBinding(msg tea.KeyMsg) (widget.Component, func() tea.Cmd, bool)
- func (fm *FocusManager) SetRoot(root widget.Container)
- type KeyBindingResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FocusManager ¶
type FocusManager struct {
// contains filtered or unexported fields
}
FocusManager walks the component tree to find focusable+active leaves and manages focus cycling (Tab/Shift-Tab), click-to-focus, and ID-based focus.
func NewFocusManager ¶
func NewFocusManager(root widget.Container) *FocusManager
NewFocusManager creates a FocusManager rooted at the given container.
func (*FocusManager) AllActiveKeyBindings ¶
func (fm *FocusManager) AllActiveKeyBindings() []key.Binding
AllActiveKeyBindings returns registered key bindings from visible, active components in tree-walk order. Duplicate key combinations are deduplicated (first-match wins, matching KeyBindingResolver.Resolve behavior). This enables building status bars, help screens, or shortcut overlays without reimplementing the component tree walk.
func (*FocusManager) CanFocusTo ¶
func (fm *FocusManager) CanFocusTo(leaf widget.Leaf) bool
CanFocusTo returns true if the leaf can receive focus.
func (*FocusManager) ChangeFocusTo ¶
ChangeFocusTo blurs the current focused leaf and focuses the new one. This is the shared primitive used by Next(), Prev(), FocusByID(), and mouse press.
func (*FocusManager) FocusByID ¶
func (fm *FocusManager) FocusByID(id string) (bool, tea.Cmd)
FocusByID focuses a specific leaf by ID. Uses ChangeFocusTo.
func (*FocusManager) FocusFirst ¶
func (fm *FocusManager) FocusFirst() tea.Cmd
FocusFirst focuses the first available leaf. Uses ChangeFocusTo.
func (*FocusManager) FocusedKeyBindings ¶
func (fm *FocusManager) FocusedKeyBindings() []key.Binding
FocusedKeyBindings returns the key bindings from the focused leaf.
func (*FocusManager) FocusedLeaf ¶
func (fm *FocusManager) FocusedLeaf() widget.Leaf
FocusedLeaf returns the currently focused leaf, or nil.
func (*FocusManager) HitTest ¶
func (fm *FocusManager) HitTest(x, y int) widget.Leaf
HitTest finds the leaf at screen coordinates. Pure lookup, no side effects.
func (*FocusManager) IsFocusChangingEvent ¶
func (fm *FocusManager) IsFocusChangingEvent(msg tea.MouseMsg) bool
IsFocusChangingEvent returns true if the mouse event should trigger a focus change.
func (*FocusManager) Leaves ¶
func (fm *FocusManager) Leaves() []widget.Leaf
Leaves returns all focusable+active leaves in tree order (depth-first walk).
func (*FocusManager) Next ¶
func (fm *FocusManager) Next() tea.Cmd
Next moves focus to the next leaf (Tab). Wraps around. Uses ChangeFocusTo.
func (*FocusManager) Prev ¶
func (fm *FocusManager) Prev() tea.Cmd
Prev moves focus to the previous leaf (Shift-Tab). Wraps around. Uses ChangeFocusTo.
func (*FocusManager) ResolveKeyBinding ¶
ResolveKeyBinding checks if the key matches any active component's registered binding. Delegates to a KeyBindingResolver rooted at the same root.
func (*FocusManager) SetRoot ¶
func (fm *FocusManager) SetRoot(root widget.Container)
SetRoot re-roots the manager to a new container tree.
type KeyBindingResolver ¶
type KeyBindingResolver struct {
// contains filtered or unexported fields
}
KeyBindingResolver resolves global key bindings by walking the component tree. It checks registered key bindings from ALL active components before focus-based routing.
func NewKeyBindingResolver ¶
func NewKeyBindingResolver(root widget.Container) *KeyBindingResolver
NewKeyBindingResolver creates a resolver rooted at the given container.
func (*KeyBindingResolver) Resolve ¶
Resolve checks if the key matches any active component's registered key binding. Children are checked before their parent (more-specific wins). Returns the matching component, the bound action, and true if a match is found.
func (*KeyBindingResolver) SetRoot ¶
func (r *KeyBindingResolver) SetRoot(root widget.Container)
SetRoot updates the root container (e.g., when window changes).