From 16a7f778dec0d4f5a53b9d5acbb2a20acecb9a22 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 19 Aug 2020 12:24:36 -0400 Subject: [PATCH] Add event::Event::unconsume(). --- include/event.hpp | 5 +++++ include/ui/MenuItem.hpp | 1 + src/ui/MenuItem.cpp | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/event.hpp b/include/event.hpp index 7a0e33bb..b4d41dc2 100644 --- a/include/event.hpp +++ b/include/event.hpp @@ -91,6 +91,11 @@ struct Base { context->consumed = true; context->target = w; } + void unconsume() const { + if (!context) + return; + context->consumed = false; + } bool isConsumed() const { if (!context) return false; diff --git a/include/ui/MenuItem.hpp b/include/ui/MenuItem.hpp index e6c7a5e0..02746efc 100644 --- a/include/ui/MenuItem.hpp +++ b/include/ui/MenuItem.hpp @@ -23,6 +23,7 @@ struct MenuItem : MenuEntry { virtual Menu* createChildMenu() { return NULL; } + void onAction(const event::Action& e) override; }; diff --git a/src/ui/MenuItem.cpp b/src/ui/MenuItem.cpp index 33c40700..66ebd28e 100644 --- a/src/ui/MenuItem.cpp +++ b/src/ui/MenuItem.cpp @@ -76,7 +76,7 @@ void MenuItem::doAction() { // Consume event by default, but allow action to un-consume it to prevent the menu from being removed. eAction.consume(this); onAction(eAction); - if (!cAction.target) + if (!cAction.consumed) return; MenuOverlay* overlay = getAncestorOfType(); @@ -86,5 +86,9 @@ void MenuItem::doAction() { } +void MenuItem::onAction(const event::Action& e) { +} + + } // namespace ui } // namespace rack