15class CatchEventBase :
public ComponentBase {
18 explicit CatchEventBase(std::function<
bool(Event)> on_event)
19 : on_event_(std::move(on_event)) {}
22 bool OnEvent(Event event)
override {
23 if (on_event_(event)) {
31 std::function<bool(Event)> on_event_;
57 std::function<
bool(
Event event)> on_event) {
58 auto out = Make<CatchEventBase>(std::move(on_event));
59 out->Add(std::move(child));
83 return [on_event = std::move(on_event)](
Component child) {
84 return CatchEvent(std::move(child), [on_event = on_event](
Event event) {
85 return on_event(std::move(event));
virtual bool OnEvent(Event)
Called in response to an event.
std::shared_ptr< ComponentBase > Component
std::function< Component(Component)> ComponentDecorator
Component CatchEvent(Component child, std::function< bool(Event)>)
Represent an event. It can be key press event, a terminal resize, or more ...