summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@digia.com>2012-11-13 07:50:43 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-14 10:36:38 +0100
commit5055183bc5a8288976f58c65b52276ad17491cad (patch)
tree81ce36908b4eafd3b324629c681a9f2fb2b48573 /src/plugins
parent26db7de13d5885067844532b5a5814181a0ddf16 (diff)
Windows: Fixed handling of key events containing ctrl modifier
QKeyEvent::key() returned the wrong value if the ctrl modifier was used in that key event. That was due to the fact that ToUnicode might not return the correct code for these events/keyboard states. While it works for alt+shift+= (us layout) and gives '+' as unicode value it just claims that it cannot translate the given state for ctrl+shift+=. So if the control modifier is used and ToUnicode return 0 toKeyOrUnicode should try again without the control modifier. Task-number: QTBUG-10781 Change-Id: I5eb9c200701b4c98a8089fc0ab1ebaa385dbeea8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index 993a8d4228..5a11aee802 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -481,6 +481,14 @@ static inline int toKeyOrUnicode(int vk, int scancode, unsigned char *kbdBuffer,
int code = 0;
QChar unicodeBuffer[5];
int res = ToUnicode(vk, scancode, kbdBuffer, reinterpret_cast<LPWSTR>(unicodeBuffer), 5, 0);
+ // When Ctrl modifier is used ToUnicode does not return correct values. In order to assign the
+ // right key the control modifier is removed for just that function if the previous call failed.
+ if (res == 0 && kbdBuffer[VK_CONTROL]) {
+ const unsigned char controlState = kbdBuffer[VK_CONTROL];
+ kbdBuffer[VK_CONTROL] = 0;
+ res = ToUnicode(vk, scancode, kbdBuffer, reinterpret_cast<LPWSTR>(unicodeBuffer), 5, 0);
+ kbdBuffer[VK_CONTROL] = controlState;
+ }
if (res)
code = unicodeBuffer[0].toUpper().unicode();