19 class CheckboxBase :
public ComponentBase,
public CheckboxOption {
21 explicit CheckboxBase(CheckboxOption option)
22 : CheckboxOption(std::move(option)) {}
27 const bool is_focused = Focused();
28 const bool is_active = Active();
30 auto entry_state = EntryState{
31 *label, *checked, is_active, is_focused || hovered_, -1,
35 return element | focus_management |
reflect(box_);
38 bool OnEvent(Event event)
override {
39 if (!CaptureMouse(event)) {
43 if (event.is_mouse()) {
44 return OnMouseEvent(event);
57 bool OnMouseEvent(Event event) {
58 hovered_ = box_.Contain(event.mouse().x, event.mouse().y);
60 if (!CaptureMouse(event)) {
79 bool Focusable() const final {
return true; }
81 bool hovered_ =
false;
109 return Make<CheckboxBase>(std::move(option));
136 option.
label = std::move(label);
138 return Make<CheckboxBase>(std::move(option));
An adapter. Own or reference a constant string. For convenience, this class convert multiple immutabl...
Element nothing(Element element)
A decoration doing absolutely nothing.
std::shared_ptr< Node > Element
std::shared_ptr< ComponentBase > Component
Element select(Element)
Set the child to be the one selected among its siblings.
Element focus(Element)
Set the child to be the one in focus globally.
Decorator reflect(Box &box)
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Component Checkbox(CheckboxOption options)
Draw checkable element.
Option for the Checkbox component.
static CheckboxOption Simple()
Option for standard Checkbox.
std::function< Element(const EntryState &)> transform
static Event Character(std::string)
An event corresponding to a given typed character.
static const Event Return