diff --git a/include/ui/MenuOverlay.hpp b/include/ui/MenuOverlay.hpp index dfbd4030..d3fd9d00 100644 --- a/include/ui/MenuOverlay.hpp +++ b/include/ui/MenuOverlay.hpp @@ -32,9 +32,7 @@ struct MenuOverlay : OpaqueWidget { OpaqueWidget::onHoverKey(e); if (e.target == this && e.action == GLFW_PRESS && e.key == GLFW_KEY_ESCAPE) { - e.target = this; requestedDelete = true; - return; } } }; diff --git a/include/ui/ScrollWidget.hpp b/include/ui/ScrollWidget.hpp index f6f3bc9e..b7fea028 100644 --- a/include/ui/ScrollWidget.hpp +++ b/include/ui/ScrollWidget.hpp @@ -142,10 +142,6 @@ struct ScrollWidget : OpaqueWidget { offset = offset.minus(e.scrollDelta); e.target = this; } - - void onHoverKey(event::HoverKey &e) override { - OpaqueWidget::onHoverKey(e); - } }; diff --git a/src/app/ModuleBrowser.cpp b/src/app/ModuleBrowser.cpp index 6a5c1843..caf14fd8 100644 --- a/src/app/ModuleBrowser.cpp +++ b/src/app/ModuleBrowser.cpp @@ -510,46 +510,46 @@ void SearchModuleField::onChange(event::Change &e) { } void SearchModuleField::onSelectKey(event::SelectKey &e) { - switch (e.key) { - case GLFW_KEY_ESCAPE: { - MenuOverlay *overlay = getAncestorOfType(); - overlay->requestedDelete = true; - e.target = this; - return; - } break; - case GLFW_KEY_UP: { - moduleBrowser->moduleList->incrementSelection(-1); - moduleBrowser->moduleList->scrollSelected(); - e.target = this; - } break; - case GLFW_KEY_DOWN: { - moduleBrowser->moduleList->incrementSelection(1); - moduleBrowser->moduleList->scrollSelected(); - e.target = this; - } break; - case GLFW_KEY_PAGE_UP: { - moduleBrowser->moduleList->incrementSelection(-5); - moduleBrowser->moduleList->scrollSelected(); - e.target = this; - } break; - case GLFW_KEY_PAGE_DOWN: { - moduleBrowser->moduleList->incrementSelection(5); - moduleBrowser->moduleList->scrollSelected(); - e.target = this; - } break; - case GLFW_KEY_ENTER: { - BrowserListItem *item = moduleBrowser->moduleList->getSelectedItem(); - if (item) { - item->doAction(); + if (e.action == GLFW_PRESS) { + switch (e.key) { + case GLFW_KEY_ESCAPE: { + MenuOverlay *overlay = getAncestorOfType(); + overlay->requestedDelete = true; e.target = this; return; - } - } break; + } break; + case GLFW_KEY_UP: { + moduleBrowser->moduleList->incrementSelection(-1); + moduleBrowser->moduleList->scrollSelected(); + e.target = this; + } break; + case GLFW_KEY_DOWN: { + moduleBrowser->moduleList->incrementSelection(1); + moduleBrowser->moduleList->scrollSelected(); + e.target = this; + } break; + case GLFW_KEY_PAGE_UP: { + moduleBrowser->moduleList->incrementSelection(-5); + moduleBrowser->moduleList->scrollSelected(); + e.target = this; + } break; + case GLFW_KEY_PAGE_DOWN: { + moduleBrowser->moduleList->incrementSelection(5); + moduleBrowser->moduleList->scrollSelected(); + e.target = this; + } break; + case GLFW_KEY_ENTER: { + BrowserListItem *item = moduleBrowser->moduleList->getSelectedItem(); + if (item) { + item->doAction(); + e.target = this; + } + } break; + } } - if (!e.target) { + if (!e.target) TextField::onSelectKey(e); - } } // Global functions diff --git a/src/app/ModuleWidget.cpp b/src/app/ModuleWidget.cpp index 16eb92ec..d227ce9a 100644 --- a/src/app/ModuleWidget.cpp +++ b/src/app/ModuleWidget.cpp @@ -318,52 +318,49 @@ void ModuleWidget::onButton(event::Button &e) { } void ModuleWidget::onHoverKey(event::HoverKey &e) { - switch (e.key) { - case GLFW_KEY_I: { - if (context()->window->isModPressed() && !context()->window->isShiftPressed()) { - reset(); - e.target = this; - return; - } - } break; - case GLFW_KEY_R: { - if (context()->window->isModPressed() && !context()->window->isShiftPressed()) { - randomize(); - e.target = this; - return; - } - } break; - case GLFW_KEY_C: { - if (context()->window->isModPressed() && !context()->window->isShiftPressed()) { - copyClipboard(); - e.target = this; - return; - } - } break; - case GLFW_KEY_V: { - if (context()->window->isModPressed() && !context()->window->isShiftPressed()) { - pasteClipboard(); - e.target = this; - return; - } - } break; - case GLFW_KEY_D: { - if (context()->window->isModPressed() && !context()->window->isShiftPressed()) { - context()->scene->rackWidget->cloneModule(this); - e.target = this; - return; - } - } break; - case GLFW_KEY_U: { - if (context()->window->isModPressed() && !context()->window->isShiftPressed()) { - disconnect(); - e.target = this; - return; - } - } break; - } - - OpaqueWidget::onHoverKey(e); + if (e.action == GLFW_PRESS) { + switch (e.key) { + case GLFW_KEY_I: { + if (context()->window->isModPressed() && !context()->window->isShiftPressed()) { + reset(); + e.target = this; + } + } break; + case GLFW_KEY_R: { + if (context()->window->isModPressed() && !context()->window->isShiftPressed()) { + randomize(); + e.target = this; + } + } break; + case GLFW_KEY_C: { + if (context()->window->isModPressed() && !context()->window->isShiftPressed()) { + copyClipboard(); + e.target = this; + } + } break; + case GLFW_KEY_V: { + if (context()->window->isModPressed() && !context()->window->isShiftPressed()) { + pasteClipboard(); + e.target = this; + } + } break; + case GLFW_KEY_D: { + if (context()->window->isModPressed() && !context()->window->isShiftPressed()) { + context()->scene->rackWidget->cloneModule(this); + e.target = this; + } + } break; + case GLFW_KEY_U: { + if (context()->window->isModPressed() && !context()->window->isShiftPressed()) { + disconnect(); + e.target = this; + } + } break; + } + } + + if (!e.target) + OpaqueWidget::onHoverKey(e); } void ModuleWidget::onDragStart(event::DragStart &e) { diff --git a/src/app/Scene.cpp b/src/app/Scene.cpp index e698094f..9028184b 100644 --- a/src/app/Scene.cpp +++ b/src/app/Scene.cpp @@ -5,6 +5,7 @@ #include "app/ModuleBrowser.hpp" #include "app/RackScrollWidget.hpp" #include "context.hpp" +#include "logger.hpp" #include @@ -67,9 +68,7 @@ void Scene::draw(NVGcontext *vg) { } void Scene::onHoverKey(event::HoverKey &e) { - OpaqueWidget::onHoverKey(e); - - if (!e.target) { + if (e.action == GLFW_PRESS) { switch (e.key) { case GLFW_KEY_N: { if (context()->window->isModPressed() && !context()->window->isShiftPressed()) { @@ -116,9 +115,13 @@ void Scene::onHoverKey(event::HoverKey &e) { } break; case GLFW_KEY_F11: { context()->window->setFullScreen(!context()->window->isFullScreen()); + e.target = this; } } } + + if (!e.target) + OpaqueWidget::onHoverKey(e); } void Scene::onPathDrop(event::PathDrop &e) {