Browse Source

KeyPress: Allow isKeyDown to handle dual-symbol keys like =/+, ;/: on Windows

develop
reuk 2 years ago
parent
commit
8aa9b01264
No known key found for this signature in database GPG Key ID: FCB43929F012EE5C
1 changed files with 6 additions and 21 deletions
  1. +6
    -21
      modules/juce_gui_basics/native/juce_Windowing_windows.cpp

+ 6
- 21
modules/juce_gui_basics/native/juce_Windowing_windows.cpp View File

@@ -4757,29 +4757,14 @@ JUCE_IMPLEMENT_SINGLETON (HWNDComponentPeer::WindowClassHolder)
//==============================================================================
bool KeyPress::isKeyCurrentlyDown (const int keyCode)
{
auto k = (SHORT) keyCode;
if ((keyCode & extendedKeyModifier) == 0)
const auto k = [&]
{
if (k >= (SHORT) 'a' && k <= (SHORT) 'z')
k += (SHORT) 'A' - (SHORT) 'a';
// Only translate if extendedKeyModifier flag is not set
const SHORT translatedValues[] = { (SHORT) ',', VK_OEM_COMMA,
(SHORT) '+', VK_OEM_PLUS,
(SHORT) '-', VK_OEM_MINUS,
(SHORT) '.', VK_OEM_PERIOD,
(SHORT) ';', VK_OEM_1,
(SHORT) ':', VK_OEM_1,
(SHORT) '/', VK_OEM_2,
(SHORT) '?', VK_OEM_2,
(SHORT) '[', VK_OEM_4,
(SHORT) ']', VK_OEM_6 };
if ((keyCode & extendedKeyModifier) != 0)
return keyCode;
for (int i = 0; i < numElementsInArray (translatedValues); i += 2)
if (k == translatedValues[i])
k = translatedValues[i + 1];
}
const auto vk = BYTE (VkKeyScan ((WCHAR) keyCode) & 0xff);
return vk != (BYTE) -1 ? vk : keyCode;
}();
return HWNDComponentPeer::isKeyDown (k);
}


Loading…
Cancel
Save