diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-04-08 23:16:43 +0200 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-04-09 12:24:27 +0200 |
commit | 96d33ab46a9244f8302a33e827c1b4ea1f3909e5 (patch) | |
tree | 88c60e78ff6d7fe69ece8132e559ec3439443365 /src/video | |
parent | 785e42a6f9d5d36b2bb98d2b941839ffc6de1fc5 (diff) | |
download | openttd-96d33ab46a9244f8302a33e827c1b4ea1f3909e5.tar.xz |
Fix #8930: [Win32] Don't handle printable keys on keydown if an edit box is in focus.
Handle printable input only when the matching WM_CHAR message is incoming.
Without an edit box, do the handling in keydown as usual to support hotkeys.
Diffstat (limited to 'src/video')
-rw-r--r-- | src/video/win32_v.cpp | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 1b3476dab..b4d3946ea 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -552,14 +552,6 @@ LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) uint scancode = GB(lParam, 16, 8); keycode = scancode == 41 ? (uint)WKC_BACKQUOTE : MapWindowsKey(wParam); - /* Silently drop all messages handled by WM_CHAR. */ - MSG msg; - if (PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) { - if ((msg.message == WM_CHAR || msg.message == WM_DEADCHAR) && GB(lParam, 16, 8) == GB(msg.lParam, 16, 8)) { - return 0; - } - } - uint charcode = MapVirtualKey(wParam, MAPVK_VK_TO_CHAR); /* No character translation? */ @@ -568,21 +560,26 @@ LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return 0; } - /* Is the console key a dead key? If yes, ignore the first key down event. */ - if (HasBit(charcode, 31) && !console) { - if (scancode == 41) { - console = true; - return 0; + /* If an edit box is in focus, wait for the corresponding WM_CHAR message. */ + if (!EditBoxInGlobalFocus()) { + /* Is the console key a dead key? If yes, ignore the first key down event. */ + if (HasBit(charcode, 31) && !console) { + if (scancode == 41) { + console = true; + return 0; + } } - } - console = false; + console = false; - /* IMEs and other input methods sometimes send a WM_CHAR without a WM_KEYDOWN, - * clear the keycode so a previous WM_KEYDOWN doesn't become 'stuck'. */ - uint cur_keycode = keycode; - keycode = 0; + /* IMEs and other input methods sometimes send a WM_CHAR without a WM_KEYDOWN, + * clear the keycode so a previous WM_KEYDOWN doesn't become 'stuck'. */ + uint cur_keycode = keycode; + keycode = 0; - return HandleCharMsg(cur_keycode, LOWORD(charcode)); + return HandleCharMsg(cur_keycode, LOWORD(charcode)); + } + + return 0; } case WM_SYSKEYDOWN: // user presses F10 or Alt, both activating the title-menu |