diff --git a/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h b/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h index 5e2773d399..85d384edeb 100644 --- a/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h +++ b/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h @@ -113,6 +113,9 @@ public: /** Flags that represent the different keys. */ enum Flags { + /** Indicates no modifier keys. */ + noModifiers = 0, + /** Shift key flag. */ shiftModifier = 1, diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index feabc5169a..95416ede31 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -545,6 +545,9 @@ public: void setTitle (const String& title) { + // Unfortunately some ancient bits of win32 mean you can only perform this operation from the message thread. + jassert (MessageManager::getInstance()->isThisTheMessageThread()); + SetWindowText (hwnd, title.toWideCharPointer()); } diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp index 4afa12ed60..c834eeae27 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp @@ -184,12 +184,19 @@ bool ComponentPeer::handleKeyPress (const int keyCode, if (keyWasUsed || deletionChecker == nullptr) break; - if (keyInfo.isKeyCode (KeyPress::tabKey) && Component::getCurrentlyFocusedComponent() != nullptr) + Component* const currentlyFocused = Component::getCurrentlyFocusedComponent(); + + if (currentlyFocused != nullptr) { - Component* const currentlyFocused = Component::getCurrentlyFocusedComponent(); - currentlyFocused->moveKeyboardFocusToSibling (! keyInfo.getModifiers().isShiftDown()); - keyWasUsed = (currentlyFocused != Component::getCurrentlyFocusedComponent()); - break; + const bool isTab = (keyInfo == KeyPress (KeyPress::tabKey, ModifierKeys::noModifiers, 0)); + const bool isShiftTab = (keyInfo == KeyPress (KeyPress::tabKey, ModifierKeys::shiftModifier, 0)); + + if (isTab || isShiftTab) + { + currentlyFocused->moveKeyboardFocusToSibling (isTab); + keyWasUsed = (currentlyFocused != Component::getCurrentlyFocusedComponent()); + break; + } } target = target->getParentComponent();