20class CheckboxBase :
public ComponentBase,
public CheckboxOption {
22 explicit CheckboxBase(CheckboxOption option)
23 : CheckboxOption(std::move(option)) {}
28 const bool is_focused = Focused();
29 const bool is_active = Active();
31 auto entry_state = EntryState{
35 is_focused || hovered_,
39 return element | focus_management |
reflect(box_);
42 bool OnEvent(Event event)
override {
43 if (!CaptureMouse(event)) {
47 if (event.is_mouse()) {
48 return OnMouseEvent(event);
61 bool OnMouseEvent(Event event) {
62 hovered_ = box_.Contain(event.mouse().x, event.mouse().y);
64 if (!CaptureMouse(event)) {
72 if (event.mouse().IsPressed()) {
81 bool Focusable() const final {
return true; }
83 bool hovered_ =
false;
112 option.
label = label;
114 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.
Component Checkbox(CheckboxOption options)
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.
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