Adding SDL_HINT_IME_PAN_PADDING "SDL_IME_PAN_PADDING".

Controls the padding between TextInputArea and IME and defaults to 0.
This commit is contained in:
DominusExult 2026-02-13 16:09:22 +01:00
parent 4e2fd57e77
commit a5134cdf3f
3 changed files with 41 additions and 5 deletions

View file

@ -642,7 +642,15 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
#endif
if (self.keyboardHeight && self.textInputRect.h) {
int rectbottom = (int)(self.textInputRect.y + self.textInputRect.h);
/* Get the pan padding from the hint (in pixels). The text input rect
* and view bounds are in UIKit points, so divide by the scale factor
* to keep the visual gap consistent across platforms.
* The iOS IME seems to apply a 15 pixel padding, so to keep it consistent
* with Android we subtract 15 pixels here. */
const char *hint = SDL_GetHint(SDL_HINT_IME_PAN_PADDING);
int panPadding = (hint && *hint) ? SDL_atoi(hint) : 0;
int padding = (int)((panPadding - 15) / self.view.contentScaleFactor);
int rectbottom = (int)(self.textInputRect.y + self.textInputRect.h + padding);
int keybottom = (int)(self.view.bounds.size.height - self.keyboardHeight);
if (keybottom < rectbottom) {
offset.y = keybottom - rectbottom;