The text input state has been changed to be window-specific.

SDL_StartTextInput(), SDL_StopTextInput(), SDL_TextInputActive(), SDL_ClearComposition(), and SDL_SetTextInputRect() all now take a window parameter.

This change also fixes IME candidate positioning when SDL_SetTextInputRect() is called before SDL_StartTextInput(), as is recommended in the documentation.
This commit is contained in:
Sam Lantinga
2024-06-22 06:16:19 -07:00
parent 258ee05655
commit 76631a0978
48 changed files with 361 additions and 339 deletions

View File

@@ -425,7 +425,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
{
BOOL shouldStartTextInput = NO;
if (!SDL_TextInputActive() && !hidingKeyboard && !rotatingOrientation) {
if (!SDL_TextInputActive(window) && !hidingKeyboard && !rotatingOrientation) {
shouldStartTextInput = YES;
}
@@ -441,7 +441,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
#endif
if (shouldStartTextInput) {
SDL_StartTextInput();
SDL_StartTextInput(window);
}
}
@@ -454,7 +454,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
{
BOOL shouldStopTextInput = NO;
if (SDL_TextInputActive() && !showingKeyboard && !rotatingOrientation) {
if (SDL_TextInputActive(window) && !showingKeyboard && !rotatingOrientation) {
shouldStopTextInput = YES;
}
@@ -462,7 +462,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
[self setKeyboardHeight:0];
if (shouldStopTextInput) {
SDL_StopTextInput();
SDL_StopTextInput(window);
}
}
@@ -567,7 +567,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
SDL_SendKeyboardKeyAutoRelease(0, SDL_SCANCODE_RETURN);
if (keyboardVisible &&
SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, SDL_FALSE)) {
SDL_StopTextInput();
SDL_StopTextInput(window);
}
return YES;
}
@@ -623,12 +623,12 @@ SDL_bool UIKit_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window)
}
}
int UIKit_SetTextInputRect(SDL_VideoDevice *_this, const SDL_Rect *rect)
int UIKit_UpdateTextInputRect(SDL_VideoDevice *_this, SDL_Window *window)
{
@autoreleasepool {
SDL_uikitviewcontroller *vc = GetWindowViewController(SDL_GetKeyboardFocus());
SDL_uikitviewcontroller *vc = GetWindowViewController(window);
if (vc != nil) {
vc.textInputRect = *rect;
vc.textInputRect = window->text_input_rect;
if (vc.keyboardVisible) {
[vc updateKeyboard];