diff options
author | falkTX <falktx@gmail.com> | 2017-07-25 11:11:25 +0200 |
---|---|---|
committer | falkTX <falktx@gmail.com> | 2017-08-03 15:48:19 +0200 |
commit | 07cf566b64d75fa02bae190282f7ade610bb3c5d (patch) | |
tree | b7d242b3c3ad7533ca98cc4b70e2e168b7aaf91f /dgl/src | |
parent | dd6e65bc88345263942d40e8e8ed46ee14ea7d3b (diff) |
Testing: handle effEditKeyUp/Down from host
Completely untested right now
Diffstat (limited to 'dgl/src')
-rw-r--r-- | dgl/src/Window.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp index 784fe89e..059eae89 100644 --- a/dgl/src/Window.cpp +++ b/dgl/src/Window.cpp @@ -845,6 +845,90 @@ struct Window::PrivateData { // ------------------------------------------------------------------- + bool handlePluginKeyboard(const bool press, const uint key) + { + DBGp("PUGL: handlePluginKeyboard : %i %i\n", press, key); + + if (fModal.childFocus != nullptr) + { + fModal.childFocus->focus(); + return true; + } + + Widget::KeyboardEvent ev; + ev.press = press; + ev.key = key; + ev.mod = static_cast<Modifier>(fView->mods); + ev.time = 0; + + if ((ev.mod & kModifierShift) != 0 && ev.key >= 'a' && ev.key <= 'z') + ev.key -= 'a' - 'A'; // a-z -> A-Z + + FOR_EACH_WIDGET_INV(rit) + { + Widget* const widget(*rit); + + if (widget->isVisible() && widget->onKeyboard(ev)) + return true; + } + + return false; + } + + bool handlePluginSpecial(const bool press, const Key key) + { + DBGp("PUGL: handlePluginSpecial : %i %i\n", press, key); + + if (fModal.childFocus != nullptr) + { + fModal.childFocus->focus(); + return true; + } + + int mods = 0x0; + + switch (key) + { + case kKeyShift: + mods |= kModifierShift; + break; + case kKeyControl: + mods |= kModifierControl; + break; + case kKeyAlt: + mods |= kModifierAlt; + break; + default: + break; + } + + if (mods != 0x0) + { + if (press) + fView->mods |= mods; + else + fView->mods &= ~(mods); + } + + Widget::SpecialEvent ev; + ev.press = press; + ev.key = key; + ev.mod = static_cast<Modifier>(fView->mods); + ev.time = 0; + + FOR_EACH_WIDGET_INV(rit) + { + Widget* const widget(*rit); + + if (widget->isVisible() && widget->onSpecial(ev)) + return true; + } + + return false; + } + + // ------------------------------------------------------------------- + Application& fApp; Window* fSelf; PuglView* fView; @@ -1200,6 +1284,16 @@ void Window::fileBrowserSelected(const char*) { } +bool Window::handlePluginKeyboard(const bool press, const uint key) +{ + return pData->handlePluginKeyboard(press, key); +} + +bool Window::handlePluginSpecial(const bool press, const Key key) +{ + return pData->handlePluginSpecial(press, key); +} + // ----------------------------------------------------------------------- StandaloneWindow::StandaloneWindow() |