|
CPGen
C++ project generator
|
A toggleable checkbox component. More...
#include <Checkbox.hpp>


Public Member Functions | |
| Checkbox (std::string label, std::function< void(bool)> on_change) | |
| Construct a Checkbox with a label and a change callback. | |
| bool | isChecked () const |
| Return the current checked state. | |
| std::string | render () const override |
| Render the checkbox as an ANSI string. | |
| bool | handleInput (Defs::Key key) override |
| Handle a key event. | |
Public Member Functions inherited from Component | |
| Component ()=default | |
| virtual | ~Component ()=default |
| Virtual destructor — components are always owned via base-class pointer. | |
| Component (const Component &)=delete | |
| Non-copyable (unique ownership). | |
| Component & | operator= (const Component &)=delete |
| Non-copyable (unique ownership). | |
| Component (Component &&)=delete | |
| Non-movable. | |
| Component & | operator= (Component &&)=delete |
| Non-movable. | |
| virtual void | setFocused (bool focused) |
| Change the focus state of this component. | |
| bool | isFocused () const |
| Return whether this component currently has keyboard focus. | |
Additional Inherited Members | |
Protected Attributes inherited from Component | |
| bool | m_is_focused |
| Current focus state, managed by setFocused. | |
A toggleable checkbox component.
Renders a Unicode checkbox glyph (checked or unchecked) followed by a text label. When the component is focused, an arrow cursor is prepended to indicate selection. Pressing Defs::Special::Enter toggles the state and fires the on_change callback.
| Checkbox::Checkbox | ( | std::string | label, |
| std::function< void(bool)> | on_change | ||
| ) |
Construct a Checkbox with a label and a change callback.
| label | Descriptive text displayed next to the checkbox glyph. |
| on_change | Callback invoked with the new checked state whenever the checkbox is toggled. |
|
overridevirtual |
Handle a key event.
Toggles the checked state when Defs::Special::Enter is pressed. All other keys are ignored (returns false).
| key | The key to process. |
true if Enter was consumed, false otherwise. Implements Component.
| bool Checkbox::isChecked | ( | ) | const |
Return the current checked state.
true if the checkbox is checked.
|
overridevirtual |
Render the checkbox as an ANSI string.
Implements Component.
