mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 10:30:28 +00:00
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.
This commit is contained in:
parent
785e42a6f9
commit
96d33ab46a
@ -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;
|
||||
|
||||
/* 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));
|
||||
}
|
||||
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;
|
||||
|
||||
return HandleCharMsg(cur_keycode, LOWORD(charcode));
|
||||
return 0;
|
||||
}
|
||||
|
||||
case WM_SYSKEYDOWN: // user presses F10 or Alt, both activating the title-menu
|
||||
|
Loading…
Reference in New Issue
Block a user