11class CatchEventBase :
public ComponentBase {
14 explicit CatchEventBase(std::function<
bool(Event)> on_event)
15 : on_event_(std::move(on_event)) {}
18 bool OnEvent(Event event)
override {
19 if (on_event_(event)) {
27 std::function<bool(Event)> on_event_;
53 std::function<
bool(
Event event)> on_event) {
55 out->Add(std::move(child));
79 return [on_event = std::move(on_event)](
Component child) {
80 return CatchEvent(std::move(child), [on_event = on_event](
Event event) {
81 return on_event(std::move(event));
virtual bool OnEvent(Event)
Called in response to an event.
std::shared_ptr< T > Make(Args &&... args)
std::function< Component(Component)> ComponentDecorator
std::shared_ptr< ComponentBase > Component
Component CatchEvent(Component child, std::function< bool(Event)>)
Represent an event. It can be key press event, a terminal resize, or more ...