Only do work to process text events if text input is active

Fixes https://github.com/libsdl-org/SDL/issues/9353
This commit is contained in:
Sam Lantinga
2024-03-25 12:49:09 -07:00
parent 658f3cdcf1
commit fa236f169b
6 changed files with 105 additions and 79 deletions

View File

@@ -837,11 +837,14 @@ static EM_BOOL Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent
static EM_BOOL Emscripten_HandleKeyPress(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
{
char text[5];
if (Emscripten_ConvertUTF32toUTF8(keyEvent->charCode, text)) {
SDL_SendKeyboardText(text);
if (SDL_TextInputActive()) {
char text[5];
if (Emscripten_ConvertUTF32toUTF8(keyEvent->charCode, text)) {
SDL_SendKeyboardText(text);
}
return EM_TRUE;
}
return SDL_EventEnabled(SDL_EVENT_TEXT_INPUT);
return EM_FALSE;
}
static EM_BOOL Emscripten_HandleFullscreenChange(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData)