Android Question How to position the cursor at the end of edittext when something is typed.

rabbit2

Member
How to position the cursor at the end of edittext when something is typed.

Short . After pressing the button, I want the cursor to be positioned at the end of the text that was previously entered in edittext. Thank you
 

Mike1970

Well-Known Member
Licensed User
Longtime User
How to position the cursor at the end of edittext when something is typed.

Short . After pressing the button, I want the cursor to be positioned at the end of the text that was previously entered in edittext. Thank you
Is not the default behaviour to have the cursor always at the end?

however you can use

B4X:
Sub EditText1_TextChanged (Old As String, New As String)
    EditText1.SelectionStart = EditText1.Text.Length
End Sub

Is this what you need?
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
I think this is what he needed Mike, although it is not very clear from the question
B4X:
Sub EditText1_EnterPressed
    EditText1.SelectionStart = EditText1.Text.Length
End Sub
Ok ok it could be, the key factor is the “selection start” 😂
 
Upvote 0
Top