B4J Question ABMInput set cursor at end of text

MichalK73

Well-Known Member
Licensed User
Longtime User
You must respond to the focus ABMInput.
Use this code, then no matter where you click in the text, the cursor will be positioned at the end.

Example code set cursor to end text where focus:
Sub inp_GotFocus()
    Dim inp As ABMInput = page.Component("inp")
    Dim t As String = inp.Text
    t=t&" "
    inp.Text = t
    inp.Refresh
    inp.Text = t.SubString2(0,t.Length-1)
    inp.Refresh
End Sub
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
This seems indeed the way to do it cross browser. It surprises me that there isn't an easier way to do it. Even in JavaScript, people have to do weird stuff like:
B4X:
$('#el').focus(function(){
  var that = this;
  setTimeout(function(){ that.selectionStart = that.selectionEnd = 10000; }, 0);
});

Alwaysbusy
 
Upvote 0
Top