Added the hint SDL_HINT_ENABLE_SCREEN_KEYBOARD to control whether the on-screen keyboard should be shown when text input is active

Fixes https://github.com/libsdl-org/SDL/issues/7160
This commit is contained in:
Sam Lantinga
2023-05-20 11:09:36 -07:00
parent 00b87f1ded
commit 69644346ac
3 changed files with 55 additions and 39 deletions

View File

@@ -4294,9 +4294,11 @@ void SDL_StartTextInput(void)
(void)SDL_EventState(SDL_TEXTEDITING, SDL_ENABLE);
/* Then show the on-screen keyboard, if any */
window = SDL_GetFocusWindow();
if (window && _this && _this->ShowScreenKeyboard) {
_this->ShowScreenKeyboard(_this, window);
if (SDL_GetHintBoolean(SDL_HINT_ENABLE_SCREEN_KEYBOARD, SDL_TRUE)) {
window = SDL_GetFocusWindow();
if (window && _this && _this->ShowScreenKeyboard) {
_this->ShowScreenKeyboard(_this, window);
}
}
/* Finally start the text input system */
@@ -4338,9 +4340,11 @@ void SDL_StopTextInput(void)
}
/* Hide the on-screen keyboard, if any */
window = SDL_GetFocusWindow();
if (window && _this && _this->HideScreenKeyboard) {
_this->HideScreenKeyboard(_this, window);
if (SDL_GetHintBoolean(SDL_HINT_ENABLE_SCREEN_KEYBOARD, SDL_TRUE)) {
window = SDL_GetFocusWindow();
if (window && _this && _this->HideScreenKeyboard) {
_this->HideScreenKeyboard(_this, window);
}
}
/* Finally disable text events */