Browse Source

Add event::Event::unconsume().

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
16a7f778de
3 changed files with 11 additions and 1 deletions
  1. +5
    -0
      include/event.hpp
  2. +1
    -0
      include/ui/MenuItem.hpp
  3. +5
    -1
      src/ui/MenuItem.cpp

+ 5
- 0
include/event.hpp View File

@@ -91,6 +91,11 @@ struct Base {
context->consumed = true; context->consumed = true;
context->target = w; context->target = w;
} }
void unconsume() const {
if (!context)
return;
context->consumed = false;
}
bool isConsumed() const { bool isConsumed() const {
if (!context) if (!context)
return false; return false;


+ 1
- 0
include/ui/MenuItem.hpp View File

@@ -23,6 +23,7 @@ struct MenuItem : MenuEntry {
virtual Menu* createChildMenu() { virtual Menu* createChildMenu() {
return NULL; return NULL;
} }
void onAction(const event::Action& e) override;
}; };






+ 5
- 1
src/ui/MenuItem.cpp View File

@@ -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. // Consume event by default, but allow action to un-consume it to prevent the menu from being removed.
eAction.consume(this); eAction.consume(this);
onAction(eAction); onAction(eAction);
if (!cAction.target)
if (!cAction.consumed)
return; return;


MenuOverlay* overlay = getAncestorOfType<MenuOverlay>(); MenuOverlay* overlay = getAncestorOfType<MenuOverlay>();
@@ -86,5 +86,9 @@ void MenuItem::doAction() {
} }




void MenuItem::onAction(const event::Action& e) {
}


} // namespace ui } // namespace ui
} // namespace rack } // namespace rack

Loading…
Cancel
Save