13 class CatchEventBase :
public ComponentBase {
16 explicit CatchEventBase(std::function<
bool(Event)> on_event)
17 : on_event_(std::move(on_event)) {}
20 bool OnEvent(Event event)
override {
21 if (on_event_(event)) {
29 std::function<bool(Event)> on_event_;
55 std::function<
bool(
Event event)> on_event) {
56 auto out = Make<CatchEventBase>(std::move(on_event));
57 out->Add(std::move(child));
81 return [on_event = std::move(on_event)](
Component child) {
82 return CatchEvent(std::move(child), [on_event = on_event](
Event event) {
83 return on_event(std::move(event));
virtual bool OnEvent(Event)
Called in response to an event.
std::shared_ptr< ComponentBase > Component
Component CatchEvent(Component child, std::function< bool(Event)>)
std::function< Component(Component)> ComponentDecorator
Represent an event. It can be key press event, a terminal resize, or more ...