Android Question Select EditText Box

Akacoo

New Member
TextBox (EditText) can be selected with TextBox1.Select() in VS. I can't do the same on B4A. :(
Example: EditText1.Select()
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4A_VqjhyxB8Vk.png
 
Upvote 0

Mark Read

Well-Known Member
Licensed User
Longtime User
Or to select the end of the text in the EditText, you can use the code from Klaus:

B4X:
EditText1.Text = "Test"
EditText1.RequestFocus
EditText1.SelectionStart = EditText1.Text.Length
 
Upvote 0

Akacoo

New Member
It was not SelectAll. I finally found it. It would be RequestFocus.
The TextBox (EditText) can be selected with TextBox.Select() in .NET. Why is RequestFocus() on B4A?

B4X:
Sub CheckBox1_CheckedChange(Checked As Boolean)
    If CheckBox1.Checked = True Then
        EditText1.Enabled=True
        IME.ShowKeyboard(EditText1)
        EditText1.RequestFocus()
    Else
        EditText1.Enabled=False
        EditText1.Text = ""
        Spinner1.Visible=False
    End If
End Sub
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Firstly welcome to the community, may you have many many many hours of great app development using the full suite of B4X development tools. Now lets answer your question.

The TextBox (EditText) can be selected with TextBox.Select() in .NET. Why is RequestFocus() on B4A?

Because B4A is not a M$ product like VS ;)
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
B4A: Textbox1.RequestFocus
VB.NET: Textbox1.Focus()

IMO, RequestFocus in B4A is more powerful as it returns True if the focus was set.
 
Upvote 0
Top