Abstract base for all TUI widgets.
More...
#include <Component.hpp>
Abstract base for all TUI widgets.
Defines the minimal interface that the View and ComponentGroup containers depend on to render and route input events.
Subclasses must implement:
- render() — return the full ANSI-formatted string representation.
- handleInput() — process one keypress and return whether it was consumed.
Subclasses may override:
- setFocused() — react to focus changes (e.g. repaint with a different colour).
◆ Component() [1/3]
◆ ~Component()
| virtual Component::~Component |
( |
| ) |
|
|
virtualdefault |
Virtual destructor — components are always owned via base-class pointer.
◆ Component() [2/3]
Non-copyable (unique ownership).
◆ Component() [3/3]
◆ handleInput()
| virtual bool Component::handleInput |
( |
Defs::Key |
key | ) |
|
|
pure virtual |
Process a single key event.
- Parameters
-
- Returns
true if the component consumed the key (no further propagation is needed), false if the event should bubble up to the parent.
Implemented in Checkbox, Input, and ComponentGroup.
◆ isFocused()
| bool Component::isFocused |
( |
| ) |
const |
|
inline |
Return whether this component currently has keyboard focus.
- Returns
true if focused.
◆ operator=() [1/2]
◆ operator=() [2/2]
Non-copyable (unique ownership).
◆ render()
| virtual std::string Component::render |
( |
| ) |
const |
|
pure virtual |
Produce the full ANSI-formatted rendering of this component.
The returned string may contain newlines and ANSI escape codes. Callers should not assume a specific line count.
- Returns
- String suitable for direct output to a terminal.
Implemented in Checkbox, Input, and ComponentGroup.
◆ setFocused()
| virtual void Component::setFocused |
( |
bool |
focused | ) |
|
|
inlinevirtual |
Change the focus state of this component.
The default implementation sets m_is_focused and is sufficient for most leaf components. Containers such as ComponentGroup override this to also update their currently focused child.
- Parameters
-
| focused | true to grant focus, false to remove it. |
Reimplemented in ComponentGroup.
◆ m_is_focused
| bool Component::m_is_focused |
|
protected |
Initial value:
Current focus state, managed by setFocused.
The documentation for this class was generated from the following file: