From 2a9b84e0cebab96ac6a82c3b7288eb82aa5cf86c Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 21 Jan 2025 22:32:28 -0500
Subject: [PATCH] On most platforms, start text input on newly-created windows.
SDL2 defaulted to text input _on_ for desktop platforms, SDL3 does not for any
platform.
Fixes #183.
---
src/sdl2_compat.c | 5 +++++
src/sdl3_syms.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index fb007e3..4317de9 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -6988,6 +6988,11 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
SDL_SetWindowData(window, PROP_WINDOW_PARENT_POINTER, parent);
}
}
+
+ #if !defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_ANDROID) // (and maybe others...?)
+ SDL3_StartTextInput(window);
+ #endif
+
return window;
}
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index b86b1b4..085a456 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -670,6 +670,7 @@ SDL3_SYM_PASSTHROUGH_RETCODE(bool,ShowSimpleMessageBox,(Uint32 a, const char *b,
SDL3_SYM(bool,ShowWindow,(SDL_Window *a),(a),return)
SDL3_SYM(void,SignalCondition,(SDL_Condition *a),(a),return)
SDL3_SYM(void,SignalSemaphore,(SDL_Semaphore *a),(a),return)
+SDL3_SYM(bool,StartTextInput,(SDL_Window *a),(a),return)
SDL3_SYM(bool,StartTextInputWithProperties,(SDL_Window *a, SDL_PropertiesID b),(a,b),return)
SDL3_SYM(bool,StopTextInput,(SDL_Window *a),(a),return)
SDL3_SYM(bool,SurfaceHasColorKey,(SDL_Surface *a),(a),return)