From 3710db47dca1cd8322e6fc26a29296b4920331b6 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Mon, 4 Feb 2019 10:31:23 -0500 Subject: [PATCH] Keycodes restored The onKeyDown handler was reading the wrong part of the data structure, so keypresses didn't navigate patches. Moreover, the handler was over-registered. Finally, once those problems were fixes, make + and - zoom and unzoom the UI. Closes #496 Keyboard Hook doesn't work Closes #479 +/- for zoom Closes #427 Keyboard hook over-registered Due to an error in windows VSTGUI this doesn't fully work on windows, with the keyboard zoom not being supported there. See issue #500 for a description of why. Former-commit-id: e0ff13f2588bbfec2ece60f9217e17522756d0fa [formerly 5aef1390d0a0711df0557e9b7d2203b2211f220c] Former-commit-id: 9e8d3af55f3c457372964310ba83c19e29da1224 Former-commit-id: f8a51113f2f5e6d738efa060371ab5fbd4cf095a --- src/common/gui/SurgeGUIEditor.cpp | 74 ++++++++++++++++--------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/src/common/gui/SurgeGUIEditor.cpp b/src/common/gui/SurgeGUIEditor.cpp index 6fdb1cfcf26..a6fd05b942f 100644 --- a/src/common/gui/SurgeGUIEditor.cpp +++ b/src/common/gui/SurgeGUIEditor.cpp @@ -419,44 +419,44 @@ void SurgeGUIEditor::refresh_mod() int32_t SurgeGUIEditor::onKeyDown(const VstKeyCode& code, CFrame* frame) { - switch (code.character) - { - case VKEY_ALT: - // modsource = modsource_editor; - // queue_refresh = true; - mod_editor = true; - refresh_mod(); - return 1; - case VKEY_TAB: - toggle_mod_editing(); - return 1; - case VKEY_LEFT: - synth->incrementCategory(false); - return 1; - case VKEY_RIGHT: - synth->incrementCategory(true); - return 1; - case VKEY_UP: - synth->incrementPatch(false); - return 1; - case VKEY_DOWN: - synth->incrementPatch(true); - return 1; - } - return -1; + if(code.virt != 0 ) + { + switch (code.virt) + { + case VKEY_TAB: + toggle_mod_editing(); + return 1; + case VKEY_LEFT: + synth->incrementCategory(false); + return 1; + case VKEY_RIGHT: + synth->incrementCategory(true); + return 1; + case VKEY_UP: + synth->incrementPatch(false); + return 1; + case VKEY_DOWN: + synth->incrementPatch(true); + return 1; + } + } + else + { + switch(code.character) + { + case '+': + setZoomFactor(getZoomFactor()+10); + return 1; + case '-': + setZoomFactor(getZoomFactor()-10); + return 1; + } + } + return -1; } int32_t SurgeGUIEditor::onKeyUp(const VstKeyCode& keyCode, CFrame* frame) { - switch (keyCode.character) - { - case VKEY_ALT: - // modsource = 0; - // queue_refresh = true; - mod_editor = false; - refresh_mod(); - return 1; - } return -1; } @@ -499,8 +499,6 @@ void SurgeGUIEditor::openOrRecreateEditor() return; assert(frame); - getFrame()->registerKeyboardHook(this); - if (editor_open) close_editor(); @@ -1255,6 +1253,10 @@ bool PLUGIN_API SurgeGUIEditor::open(void* parent, const PlatformType& platformT synth = (sub3_synth*)plug->plugin_instance; #endif*/ + /* + ** Register only once (when we open) + */ + frame->registerKeyboardHook(this); openOrRecreateEditor(); return true;