mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-14 02:07:49 +00:00
Fix iOS text input not working with password integration 2
This commit is contained in:
parent
defd7895da
commit
7af479bc53
1 changed files with 12 additions and 1 deletions
|
|
@ -578,6 +578,14 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
|
|||
|
||||
- (void)textFieldTextDidChange:(NSNotification *)notification
|
||||
{
|
||||
// When opening a password manager overlay to select a password and have it auto-filled,
|
||||
// text input becomes stopped as a result of the keyboard being hidden or the text field losing focus.
|
||||
// As a workaround, ensure text input is activated on any changes to the text field.
|
||||
bool startTextInputMomentarily = !SDL_TextInputActive(window);
|
||||
|
||||
if (startTextInputMomentarily)
|
||||
SDL_StartTextInput(window);
|
||||
|
||||
if (textField.markedTextRange == nil) {
|
||||
if (isOTPMode && labs((NSInteger)textField.text.length - (NSInteger)committedText.length) != 1) {
|
||||
return;
|
||||
|
|
@ -616,6 +624,9 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
|
|||
}
|
||||
committedText = textField.text;
|
||||
}
|
||||
|
||||
if (startTextInputMomentarily)
|
||||
SDL_StopTextInput(window);
|
||||
}
|
||||
|
||||
- (void)updateKeyboard
|
||||
|
|
@ -661,7 +672,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
|
|||
- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
|
||||
{
|
||||
if (!isOTPMode) {
|
||||
if (textField.markedTextRange == nil && textField.text.length < 16) {
|
||||
if (textField.markedTextRange == nil && [string length] == 0 && textField.text.length < 16) {
|
||||
[self resetTextState];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue