19class 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();
29 auto entry_state = EntryState{
30 *label, *checked, is_active, is_focused || hovered_, -1,
39 bool OnEvent(Event event)
override {
40 if (!CaptureMouse(event)) {
44 if (event.is_mouse()) {
45 return OnMouseEvent(event);
49 if (event == Event::Character(
' ') || event ==
Event::Return) {
58 bool OnMouseEvent(Event event) {
59 hovered_ = box_.Contain(event.mouse().x, event.mouse().y);
61 if (!CaptureMouse(event)) {
79 bool Focusable() const final {
return true; }
81 bool hovered_ =
false;
136 option.
label = std::move(label);
一个适配器。拥有或引用一个常量字符串。为了方便,这个 类将多个不可变字符串转换为共享表示。
static CheckboxOption Simple()
标准Checkbox的选项。
static const Event Return
std::function< Element(const EntryState &)> transform
Component Checkbox(CheckboxOption options)
绘制可勾选元素。
Element focus(Element)
将 child 设置为其同级元素中获得焦点的元素。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
std::shared_ptr< T > Make(Args &&... args)
std::shared_ptr< Node > Element
Decorator reflect(Box &box)
std::shared_ptr< ComponentBase > Component