|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
Makes an entity able to own the input focus, and holds whether it owns it and what to call when it gains or loses it. More...
#include <headers/guillaume/components/focus.hpp>


Public Types | |
| using | Handler = std::function<void(void)> |
| Focus change callback. | |
Public Member Functions | |
| Focus (void)=default | |
| Construct an unfocused component without handler. | |
| ~Focus (void)=default | |
| Default destructor. | |
| void | setOnFocusGainedHandler (const Handler &handler) |
| Store the callback run when the entity gains the focus. | |
| Handler | getOnFocusGainedHandler (void) const |
| Get the callback run when the entity gains the focus. | |
| void | setOnFocusLostHandler (const Handler &handler) |
| Store the callback run when the entity loses the focus. | |
| Handler | getOnFocusLostHandler (void) const |
| Get the callback run when the entity loses the focus. | |
| bool | isFocused (void) const |
| Check whether the entity owns the input focus. | |
| void | setFocused (bool focused) |
| Record whether the entity owns the input focus. | |
| Public Member Functions inherited from guillaume::ecs::Component | |
| bool | hasChanged (void) const |
| Tell whether a value of the component changed since the flags were last reset (the end of the previous frame). | |
| void | setHasChanged (bool hasChanged) |
| Raise or lower the changed flag. | |
| Component (void)=default | |
| Create a component that is not marked as changed. | |
| virtual | ~Component (void)=default |
| Virtual destructor, so components can be destroyed through the base class. | |
Makes an entity able to own the input focus, and holds whether it owns it and what to call when it gains or loses it.
At most one entity is focused at a time; systems::Focus decides which. It runs in the Event phase, gives the focus to an entity that is clicked (left mouse button, hand button A, B, X or Y, pinch or poke) or reached with Tab / Shift+Tab, then writes the focused flag here and in StyleState and calls the handlers. An entity disabled through StyleState cannot take or keep the focus.
To move the focus from code, call systems::Focus::setFocus or systems::Focus::clearFocus: setFocused() only stores the flag and does not take the focus away from the entity that owns it. Tab order and exclusion from the Tab traversal are set on Accessibility.
| using guillaume::components::Focus::Handler = std::function<void(void)> |
| Focus::Handler guillaume::components::Focus::getOnFocusGainedHandler | ( | void | ) | const |
| Focus::Handler guillaume::components::Focus::getOnFocusLostHandler | ( | void | ) | const |
| bool guillaume::components::Focus::isFocused | ( | void | ) | const |
Check whether the entity owns the input focus.
Definition at line 48 of file focus.cpp.

| void guillaume::components::Focus::setFocused | ( | bool | focused | ) |
Record whether the entity owns the input focus.
Called by systems::Focus; it calls no handler and does not change which entity the system considers focused. Marks the component changed only when the flag differs.
| focused | True when the entity owns the focus. |
Definition at line 53 of file focus.cpp.

| void guillaume::components::Focus::setOnFocusGainedHandler | ( | const Handler & | handler | ) |
Store the callback run when the entity gains the focus.
systems::Focus calls it each time it sets the focus on the entity, including when the entity already owned it. Always marks the component changed.
| handler | The callback, or nullptr to remove the current one. |
Definition at line 27 of file focus.cpp.


| void guillaume::components::Focus::setOnFocusLostHandler | ( | const Handler & | handler | ) |
Store the callback run when the entity loses the focus.
systems::Focus calls it when the focus moves to another entity or is cleared. Always marks the component changed.
| handler | The callback, or nullptr to remove the current one. |
Definition at line 38 of file focus.cpp.
