1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Simplified text input handling, fixes hotkeys on windows with text input

This commit is contained in:
Ivan Savenko
2023-07-04 18:42:52 +03:00
parent 81b9aec527
commit 900b1c1763
8 changed files with 58 additions and 41 deletions

View File

@@ -33,6 +33,12 @@ void InputSourceKeyboard::handleEventKeyDown(const SDL_KeyboardEvent & key)
if(key.repeat != 0)
return; // ignore periodic event resends
if (SDL_IsTextInputActive() == SDL_TRUE)
{
if (key.keysym.sym >= ' ' && key.keysym.sym < 0x80)
return; // printable character - will be handled as text input
}
assert(key.state == SDL_PRESSED);
if(key.keysym.sym >= SDLK_F1 && key.keysym.sym <= SDLK_F15 && settings["session"]["spectate"].Bool())
@@ -77,6 +83,12 @@ void InputSourceKeyboard::handleEventKeyUp(const SDL_KeyboardEvent & key)
if(key.repeat != 0)
return; // ignore periodic event resends
if (SDL_IsTextInputActive() == SDL_TRUE)
{
if (key.keysym.sym >= ' ' && key.keysym.sym < 0x80)
return; // printable character - will be handled as text input
}
assert(key.state == SDL_RELEASED);
auto shortcutsVector = GH.shortcuts().translateKeycode(key.keysym.sym);