From 35a7e8e864ac3a7f8a3869029ff48d404fea56bb Mon Sep 17 00:00:00 2001 From: Turtle Dove Date: Wed, 15 Jul 2026 09:37:12 -0500 Subject: [PATCH] Backends: SDL2: restore SDL_StartTextInput()/SDL_StopTextInput() calls on Android (#7636, #9474) --- backends/imgui_impl_android.cpp | 1 + backends/imgui_impl_sdl2.cpp | 13 +++++++++++++ docs/CHANGELOG.txt | 7 +++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/backends/imgui_impl_android.cpp b/backends/imgui_impl_android.cpp index f324c7dce..08b3de08a 100644 --- a/backends/imgui_impl_android.cpp +++ b/backends/imgui_impl_android.cpp @@ -24,6 +24,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) // 2026-07-15: Inputs: clear mouse position on touch release (AMOTION_EVENT_ACTION_UP) to prevent items from staying in hovered state. (#6627, #9474) +// 2023-04-11: Inputs: calling new io.AddMouseSourceEvent() to discriminate Mouse from Touch events. // 2022-09-26: Inputs: renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported). // 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago) with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion. // 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+). diff --git a/backends/imgui_impl_sdl2.cpp b/backends/imgui_impl_sdl2.cpp index 4def68dd6..eec4e0075 100644 --- a/backends/imgui_impl_sdl2.cpp +++ b/backends/imgui_impl_sdl2.cpp @@ -21,6 +21,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2026-07-15: Inputs: restore SDL_StartTextInput()/SDL_StopTextInput() in IME handler for on-screen keyboard support on Android/mobile. (#7636, #9474) // 2026-04-16: Made ImGui_ImplSDL2_GetContentScaleForWindow(), ImGui_ImplSDL2_GetContentScaleForDisplay() helpers return a minimum of 1.0f, as some Linux setup seems to report <1.0f value and this breaks scaling border size. (#9369) // 2026-02-13: Inputs: systems other than X11 are back to starting mouse capture on mouse down (reverts 2025-02-26 change). Only X11 requires waiting for a drag by default (not ideal, but a better default for X11 users). Added ImGui_ImplSDL2_SetMouseCaptureMode() for X11 debugger users. (#3650, #6410, #9235) // 2026-01-15: Changed GetClipboardText() handler to return nullptr on error aka clipboard contents is not text. Consistent with other backends. (#9168) @@ -205,6 +206,18 @@ static void ImGui_ImplSDL2_PlatformSetImeData(ImGuiContext*, ImGuiViewport*, ImG r.w = 1; r.h = (int)data->InputLineHeight; SDL_SetTextInputRect(&r); + +#ifdef __ANDROID__ + // SDL_StartTextInput() is needed on Android (and some other platforms) to show the on-screen keyboard. (#7636, #9474, #6306) + // It was removed in a7703fe6 due to concerns about its relation to desktop IME, but is required on mobile. + SDL_StartTextInput(); +#endif + } + else + { +#ifdef __ANDROID__ + SDL_StopTextInput(); +#endif } } diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 05aaa3162..f4f699220 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -151,8 +151,8 @@ Other Changes: - Added IM_DEBUG_BREAK() handler for GCC+AArch64/ARM64. [@tom-seddon] - Backends: - Android: - - Clear mouse position on touch release (AMOTION_EVENT_ACTION_UP) to prevent - items from staying in hovered state. (#6627, #9474) [@Turtle-PB] + - Clear mouse position on touch release (AMOTION_EVENT_ACTION_UP) to prevent + items from staying in hovered state. (#6627, #9474) [@Turtle-PB] - Metal4: - Added new Metal 4 backend (forked from Metal 3 backend). (#9458, #9451) [@AmelieHeinrich] - Added Metal-cpp support enabled with `IMGUI_IMPL_METAL_CPP` define. (#9461) [@MERL10N] @@ -161,6 +161,9 @@ Other Changes: Fixes an issue running on macOS with Wine. [#9427, #6577) [@perminovVS] - Expose selected render state in ImGui_ImplOpenGL3_RenderState, allowing to dynamically select between use of glBindSampler() and glTexParameter(). (#9378) + - SDL2: + - Restore SDL_StartTextInput()/SDL_StopTextInput() in IME handler for on-screen keyboard + support on Android. (#7636, #9474) [@Turtle-PB] - SDLRenderer3: - Fixed sampler change which didn't work on all graphics backends. (#7616, #9470, #9378) - Fixed default sampler not being Linear. Regression in 1.92.8. (#7616, #9470, #9378) [@ShiroKSH]