1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-25 02:04:23 +00:00

Fix incorrect key-code translation which could occur for special key-codes in KeyPress::isKeyCurrentlyDown on Windows

This commit is contained in:
hogliux 2015-06-10 10:03:29 +01:00
parent f92828f1f0
commit 324f26cc11

View file

@ -2968,24 +2968,27 @@ bool KeyPress::isKeyCurrentlyDown (const int keyCode)
{
SHORT k = (SHORT) keyCode;
if ((keyCode & extendedKeyModifier) == 0
&& (k >= (SHORT) 'a' && k <= (SHORT) 'z'))
k += (SHORT) 'A' - (SHORT) 'a';
if ((keyCode & extendedKeyModifier) == 0)
{
if (k >= (SHORT) 'a' && k <= (SHORT) 'z')
k += (SHORT) 'A' - (SHORT) 'a';
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 };
// 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 };
for (int i = 0; i < numElementsInArray (translatedValues); i += 2)
if (k == translatedValues [i])
k = translatedValues [i + 1];
for (int i = 0; i < numElementsInArray (translatedValues); i += 2)
if (k == translatedValues [i])
k = translatedValues [i + 1];
}
return HWNDComponentPeer::isKeyDown (k);
}