mirror of
https://github.com/encounter/SDL.git
synced 2025-06-16 19:43:47 +00:00
Split long text input into multiple events if needed (thanks @zreedy!)
This commit is contained in:
parent
232c3556ac
commit
2e801b1ae7
@ -867,10 +867,14 @@ SDL_SendKeyboardText(const char *text)
|
|||||||
posted = 0;
|
posted = 0;
|
||||||
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
|
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
size_t i = 0, length = SDL_strlen(text);
|
||||||
|
|
||||||
event.text.type = SDL_TEXTINPUT;
|
event.text.type = SDL_TEXTINPUT;
|
||||||
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
|
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
|
||||||
SDL_utf8strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
|
while (i < length) {
|
||||||
posted = (SDL_PushEvent(&event) > 0);
|
i += SDL_utf8strlcpy(event.text.text, text + i, SDL_arraysize(event.text.text));
|
||||||
|
posted |= (SDL_PushEvent(&event) > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (posted);
|
return (posted);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user