Split long text input into multiple events if needed (thanks @zreedy!)

This commit is contained in:
Sam Lantinga 2022-03-04 10:49:12 -08:00
parent 232c3556ac
commit 2e801b1ae7

View file

@ -867,10 +867,14 @@ SDL_SendKeyboardText(const char *text)
posted = 0;
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
SDL_Event event;
size_t i = 0, length = SDL_strlen(text);
event.text.type = SDL_TEXTINPUT;
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
SDL_utf8strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
posted = (SDL_PushEvent(&event) > 0);
while (i < length) {
i += SDL_utf8strlcpy(event.text.text, text + i, SDL_arraysize(event.text.text));
posted |= (SDL_PushEvent(&event) > 0);
}
}
return (posted);
}