@@ -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; | |||
} | |||
} | |||
}; | |||
@@ -142,10 +142,6 @@ struct ScrollWidget : OpaqueWidget { | |||
offset = offset.minus(e.scrollDelta); | |||
e.target = this; | |||
} | |||
void onHoverKey(event::HoverKey &e) override { | |||
OpaqueWidget::onHoverKey(e); | |||
} | |||
}; | |||
@@ -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<MenuOverlay>(); | |||
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<MenuOverlay>(); | |||
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 | |||
@@ -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) { | |||
@@ -5,6 +5,7 @@ | |||
#include "app/ModuleBrowser.hpp" | |||
#include "app/RackScrollWidget.hpp" | |||
#include "context.hpp" | |||
#include "logger.hpp" | |||
#include <thread> | |||
@@ -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) { | |||