FocusManager
FocusManager
Section titled “FocusManager”#include <FocusManager.hpp>Manages focus among widgets, including traversal and event dispatching.
Public Methods
Section titled “Public Methods”| Return | Name | Description |
|---|---|---|
void | setFocus | Set focus to any widget. |
void | clearFocus | Clear focus from any widget. |
std::shared_ptr< Widget > | focused const inline | Get the currently focused widget, if any. |
void | focusNext | Move focus to the next focusable widget in the tree. |
void | focusPrev | Move focus to the previous focusable widget in the tree. |
bool | dispatchToFocused | Dispatch an event to the currently focused widget, if any. |
bool | dispatch | Dispatch an event This also includes handling of global focus-related keys like Tab and Escape. |
void | focusTopOverlay | Focus the top overlay from the overlay stack. |
setFocus
Section titled “setFocus”void setFocus(std::shared_ptr< Widget > w)Set focus to any widget.
Parameters
Section titled “Parameters”wThe widget to receive focus.
clearFocus
Section titled “clearFocus”void clearFocus()Clear focus from any widget.
focused
Section titled “focused”const inline
inline std::shared_ptr< Widget > focused() constGet the currently focused widget, if any.
focusNext
Section titled “focusNext”void focusNext(std::shared_ptr< Widget > root)Move focus to the next focusable widget in the tree.
Parameters
Section titled “Parameters”rootThe root widget for focus traversal
focusPrev
Section titled “focusPrev”void focusPrev(std::shared_ptr< Widget > root)Move focus to the previous focusable widget in the tree.
Parameters
Section titled “Parameters”rootThe root widget for focus traversal
dispatchToFocused
Section titled “dispatchToFocused”bool dispatchToFocused(const events::Event & e)Dispatch an event to the currently focused widget, if any.
Parameters
Section titled “Parameters”eThe event to dispatch
dispatch
Section titled “dispatch”bool dispatch(const events::Event & e, std::shared_ptr< Widget > root)Dispatch an event This also includes handling of global focus-related keys like Tab and Escape.
Parameters
Section titled “Parameters”-
eThe event to dispatch -
rootThe root widget for focus traversal if needed (e.g. on Tab key))
focusTopOverlay
Section titled “focusTopOverlay”void focusTopOverlay()Focus the top overlay from the overlay stack.
Private Attributes
Section titled “Private Attributes”| Return | Name | Description |
|---|---|---|
std::weak_ptr< Widget > | current | The currently focused Widget. |
current
Section titled “current”std::weak_ptr< Widget > currentThe currently focused Widget.
Private Methods
Section titled “Private Methods”| Return | Name | Description |
|---|---|---|
void | collectFocusable | Collect the focusable widgets Recursively traverses the widget tree to find all focusable widgets and adds them to the output vector. |
collectFocusable
Section titled “collectFocusable”void collectFocusable(std::shared_ptr< Widget > w, std::vector< std::shared_ptr< Widget > > & out)Collect the focusable widgets Recursively traverses the widget tree to find all focusable widgets and adds them to the output vector.
Parameters
Section titled “Parameters”-
wThe widget to start traversal from -
outThe output vector to collect focusable widgets into