Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UITextField setText: should move caret position of underlying TextBox to end. #502

Merged
merged 1 commit into from
May 24, 2016

Conversation

ehren
Copy link
Contributor

@ehren ehren commented May 17, 2016

Ensures caret position is correct if we programmatically gain focus (becomeFirstResponder).


I'm in a situation where I have certain elements e.g. tableviewcells which, when tapped, programmatically set focus on a text field in the element (so that it's easier to bring the keyboard up without having to touch on exactly the bounds of the text field). There could also be situations where e.g. actual touches on a UITextField are blocked by another transparent UIView covering the field - with actual beginning editing of the covered UITextField handled by |becomeFirstResponder|.

This change ensures that in the above scenarios the caret is not at the beginning of the textfield's text.

… to end.

Ensures caret position is correct if we programmatically gain focus (becomeFirstResponder).
// Ensure caret at end of field in case we programmatically
// gain focus (becomeFirstResponder) after the text is set:
_textBox.selectionStart = [_text length];
_textBox.selectionLength = 0;
Copy link
Contributor

@jaredhms jaredhms May 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want the same behavior for _passwordBox? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PasswordBox doesn't have the SelectionStart/Length properties. However it already implements the right functionality automatically. (I did the basic test which is to programmatically set the text then programmatically gain focus with a secureMode UITextField - the caret just appears at the end)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for validating


In reply to: 63553197 [](ancestors = 63553197)

@jaredhms
Copy link
Contributor

@yiyang-msft is added to the review. #Closed

@jaredhms
Copy link
Contributor

:shipit:

@yiyang-msft
Copy link
Contributor

:shipit:

@Ramu-msft Ramu-msft merged commit a36d014 into microsoft:master May 24, 2016
@Ramu-msft
Copy link
Member

Thanks for your contribution.

@ehren ehren deleted the settext-caret branch May 24, 2016 18:49
rajsesh pushed a commit that referenced this pull request Jun 3, 2016
There are some standing issues with the libobjc2 associated objects
implementation.

Fixes #501.
Addresses some concerns from #502.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants