Android Question Insert text of button at current cursor position of EditText

U

unba1300

Guest
How would I code to insert the text property of a button into an EditText at the current cursor position? Thanks.
 
U

unba1300

Guest
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.
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
Thanks again.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User


Nice.

You're welcome
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…