From 3fdf1734da7ba51e025f49e11e920aa8db12187b Mon Sep 17 00:00:00 2001 From: JamesPerlman Date: Fri, 30 Sep 2016 15:49:37 -0500 Subject: [PATCH] Typing when token is selected now adds input text Before this change, when you type while a token is selected, it adds text to the invisibleTextField, with no user feedback. If you type multiple characters, you have to delete those characters before the token is deleted. Now if you type while a token is selected, it deselects the token and adds the text to the visible inputTextField. --- VENTokenField/VENTokenField.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/VENTokenField/VENTokenField.m b/VENTokenField/VENTokenField.m index afcc026..66eb1ea 100644 --- a/VENTokenField/VENTokenField.m +++ b/VENTokenField/VENTokenField.m @@ -342,6 +342,7 @@ - (void)layoutInvisibleTextField [self.invisibleTextField setAutocorrectionType:self.autocorrectionType]; [self.invisibleTextField setAutocapitalizationType:self.autocapitalizationType]; self.invisibleTextField.backspaceDelegate = self; + [self.invisibleTextField addTarget:self action:@selector(invisibleTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; [self addSubview:self.invisibleTextField]; } @@ -451,6 +452,14 @@ - (void)inputTextFieldDidChange:(UITextField *)textField } } +- (void)invisibleTextFieldDidChange:(UITextField *)textField +{ + _inputTextField.text = [_inputTextField.text?:@"" stringByAppendingString:_invisibleTextField.text]; + _invisibleTextField.text = nil; + [_inputTextField becomeFirstResponder]; + [self inputTextFieldDidChange:_inputTextField]; +} + - (void)handleSingleTap:(UITapGestureRecognizer *)gestureRecognizer { [self becomeFirstResponder];