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->target = w;
}
void unconsume() const {
if (!context)
return;
context->consumed = false;
}
bool isConsumed() const {
if (!context)
return false;


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

@@ -23,6 +23,7 @@ struct MenuItem : MenuEntry {
virtual Menu* createChildMenu() {
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.
eAction.consume(this);
onAction(eAction);
if (!cAction.target)
if (!cAction.consumed)
return;

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


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


} // namespace ui
} // namespace rack

Loading…
Cancel
Save