diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m index c4345578d1752..d4ba09573b86f 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.m +++ b/src/video/uikit/SDL_uikitviewcontroller.m @@ -528,6 +528,7 @@ - (bool)stopTextInput return true; } + [self resetTextState]; return [textField resignFirstResponder]; } @@ -657,8 +658,7 @@ - (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRan { if (textField.markedTextRange == nil) { if (textField.text.length < 16) { - textField.text = obligateForBackspace; - committedText = textField.text; + [self resetTextState]; } } return YES; @@ -675,6 +675,12 @@ - (BOOL)textFieldShouldReturn:(UITextField *)_textField return YES; } +- (void)resetTextState +{ + textField.text = obligateForBackspace; + committedText = textField.text; +} + #endif @end