U
unba1300
Guest
How would I code to insert the text property of a button into an EditText at the current cursor position? Thanks.
How would I code to insert the text property of a button into an EditText at the current cursor position? Thanks.
Sub Button1_Click
Dim Start As Int = EditText1.SelectionStart
EditText1.Text = EditText1.Text.SubString2(0, Start) _
& Button1.Text _
& EditText1.Text.SubString(Start)
End Sub
Sub Button1_Click
Dim Start As Int = EditText1.SelectionStart
EditText1.Text = EditText1.Text.SubString2(0, Start-1) _
& Button1.Text & " " _
& EditText1.Text.SubString(Start)
End Sub
Thanks LM. I have some EditTexts where when the user enters an open bracket, a panel appears with some buttons and clicking one of the buttons enters that text at the cursor position. It basically shows the user what options can be entered in that particular EditText and saves them some typing. Modified the code slightly to erase their first open bracket and add a space after the button's text.
Thanks again.B4X:Sub Button1_Click Dim Start As Int = EditText1.SelectionStart EditText1.Text = EditText1.Text.SubString2(0, Start-1) _ & Button1.Text & " " _ & EditText1.Text.SubString(Start) End Sub