Browse Source

Fix iOS text input not working with password integration 2

Salman Alshamrani 3 months ago
parent
commit
7af479bc53
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/video/uikit/SDL_uikitviewcontroller.m

+ 12 - 1
src/video/uikit/SDL_uikitviewcontroller.m

@@ -578,6 +578,14 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
 
 
 - (void)textFieldTextDidChange:(NSNotification *)notification
 - (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 (textField.markedTextRange == nil) {
         if (isOTPMode && labs((NSInteger)textField.text.length - (NSInteger)committedText.length) != 1) {
         if (isOTPMode && labs((NSInteger)textField.text.length - (NSInteger)committedText.length) != 1) {
             return;
             return;
@@ -616,6 +624,9 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
         }
         }
         committedText = textField.text;
         committedText = textField.text;
     }
     }
+
+    if (startTextInputMomentarily)
+        SDL_StopTextInput(window);
 }
 }
 
 
 - (void)updateKeyboard
 - (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
 - (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
 {
 {
     if (!isOTPMode) {
     if (!isOTPMode) {
-        if (textField.markedTextRange == nil && textField.text.length < 16) {
+        if (textField.markedTextRange == nil && [string length] == 0 && textField.text.length < 16) {
             [self resetTextState];
             [self resetTextState];
         }
         }
     }
     }