IME Composition Truncation + SDL_IsTextInputShown + SDL_ClearComposition (#5398)

* Fixes for IME Composition Truncation + Addition of SDL_ClearComposition, SDL_IsTextInputShown

* Fixed: Documentation and code style issues raised during code review.
This commit is contained in:
Zach Reedy
2022-03-11 17:45:17 -05:00
committed by GitHub
parent 9de97e19cc
commit d14a126383
12 changed files with 210 additions and 12 deletions

View File

@@ -894,6 +894,22 @@ SDL_SendEditingText(const char *text, int start, int length)
event.edit.start = start;
event.edit.length = length;
SDL_utf8strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
if (SDL_GetHintBoolean(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, SDL_FALSE) &&
SDL_strlen(text) > SDL_arraysize(event.text.text)) {
event.editExt.type = SDL_TEXTEDITING_EXT;
event.editExt.windowID = keyboard->focus ? keyboard->focus->id : 0;
event.editExt.text = text ? SDL_strdup(text) : NULL;
event.editExt.start = start;
event.editExt.length = length;
} else {
event.edit.type = SDL_TEXTEDITING;
event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0;
event.edit.start = start;
event.edit.length = length;
SDL_utf8strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
}
posted = (SDL_PushEvent(&event) > 0);
}
return (posted);