mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-14 22:05:59 +00:00
Add SetTextInputProperties
to video device API and fix iOS handling
This commit is contained in:

committed by
Sam Lantinga

parent
5d09656afa
commit
972c6d0b82
@@ -352,6 +352,7 @@ struct SDL_VideoDevice
|
|||||||
bool (*HasScreenKeyboardSupport)(SDL_VideoDevice *_this);
|
bool (*HasScreenKeyboardSupport)(SDL_VideoDevice *_this);
|
||||||
void (*ShowScreenKeyboard)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props);
|
void (*ShowScreenKeyboard)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props);
|
||||||
void (*HideScreenKeyboard)(SDL_VideoDevice *_this, SDL_Window *window);
|
void (*HideScreenKeyboard)(SDL_VideoDevice *_this, SDL_Window *window);
|
||||||
|
void (*SetTextInputProperties)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props);
|
||||||
bool (*IsScreenKeyboardShown)(SDL_VideoDevice *_this, SDL_Window *window);
|
bool (*IsScreenKeyboardShown)(SDL_VideoDevice *_this, SDL_Window *window);
|
||||||
|
|
||||||
// Clipboard
|
// Clipboard
|
||||||
|
@@ -5299,6 +5299,10 @@ bool SDL_StartTextInputWithProperties(SDL_Window *window, SDL_PropertiesID props
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_this->SetTextInputProperties) {
|
||||||
|
_this->SetTextInputProperties(_this, window, props);
|
||||||
|
}
|
||||||
|
|
||||||
// Show the on-screen keyboard, if desired
|
// Show the on-screen keyboard, if desired
|
||||||
if (AutoShowingScreenKeyboard() && !SDL_ScreenKeyboardShown(window)) {
|
if (AutoShowingScreenKeyboard() && !SDL_ScreenKeyboardShown(window)) {
|
||||||
if (_this->ShowScreenKeyboard) {
|
if (_this->ShowScreenKeyboard) {
|
||||||
|
@@ -99,6 +99,7 @@ static SDL_VideoDevice *UIKit_CreateDevice(void)
|
|||||||
device->HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport;
|
device->HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport;
|
||||||
device->StartTextInput = UIKit_StartTextInput;
|
device->StartTextInput = UIKit_StartTextInput;
|
||||||
device->StopTextInput = UIKit_StopTextInput;
|
device->StopTextInput = UIKit_StopTextInput;
|
||||||
|
device->SetTextInputProperties = UIKit_SetTextInputProperties;
|
||||||
device->IsScreenKeyboardShown = UIKit_IsScreenKeyboardShown;
|
device->IsScreenKeyboardShown = UIKit_IsScreenKeyboardShown;
|
||||||
device->UpdateTextInputArea = UIKit_UpdateTextInputArea;
|
device->UpdateTextInputArea = UIKit_UpdateTextInputArea;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -90,6 +90,7 @@
|
|||||||
bool UIKit_HasScreenKeyboardSupport(SDL_VideoDevice *_this);
|
bool UIKit_HasScreenKeyboardSupport(SDL_VideoDevice *_this);
|
||||||
bool UIKit_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props);
|
bool UIKit_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props);
|
||||||
bool UIKit_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window);
|
bool UIKit_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window);
|
||||||
|
void UIKit_SetTextInputProperties(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props);
|
||||||
bool UIKit_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window);
|
bool UIKit_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window);
|
||||||
bool UIKit_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window);
|
bool UIKit_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -470,6 +470,21 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
|
|||||||
} else {
|
} else {
|
||||||
textField.enablesReturnKeyAutomatically = NO;
|
textField.enablesReturnKeyAutomatically = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!textField.window) {
|
||||||
|
/* textField has not been added to the view yet,
|
||||||
|
we don't have to do anything. */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the text field needs to be re-added to the view in order to update correctly.
|
||||||
|
UIView *superview = textField.superview;
|
||||||
|
[textField removeFromSuperview];
|
||||||
|
[superview addSubview:textField];
|
||||||
|
|
||||||
|
if (SDL_TextInputActive(window)) {
|
||||||
|
[textField becomeFirstResponder];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* requests the SDL text field to become focused and accept text input.
|
/* requests the SDL text field to become focused and accept text input.
|
||||||
@@ -672,7 +687,6 @@ bool UIKit_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_Proper
|
|||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
SDL_uikitviewcontroller *vc = GetWindowViewController(window);
|
SDL_uikitviewcontroller *vc = GetWindowViewController(window);
|
||||||
[vc setTextFieldProperties:props];
|
|
||||||
return [vc startTextInput];
|
return [vc startTextInput];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -685,6 +699,14 @@ bool UIKit_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIKit_SetTextInputProperties(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props)
|
||||||
|
{
|
||||||
|
@autoreleasepool {
|
||||||
|
SDL_uikitviewcontroller *vc = GetWindowViewController(window);
|
||||||
|
[vc setTextFieldProperties:props];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool UIKit_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window)
|
bool UIKit_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
Reference in New Issue
Block a user