I have a ListView of items that can be clicked on to be inserted into a text document in a TextArea view.
Here's how I'm doing it...
Is there a better way? Does a TextArea have an InsertAt() type function? I couldn't find one, but that doesn't mean it doesn't exist!
Here's how I'm doing it...
B4X:
Private Sub list_Fields_MouseClicked (EventData As MouseEvent)
Private iText As String = "{{" & list_Fields.SelectedItem & "}}"
Private ip As Int = txt_EmailBody.SelectionStart
Private oldText, newText As String
list_Fields.SelectedIndex = -1
oldText = txt_EmailBody.Text
newText = oldText.SubString2(0,ip) & iText & oldText.SubString(ip)
txt_EmailBody.Text = newText
txt_EmailBody.SelectionStart = ip + iText.Length
txt_EmailBody.RequestFocus
End Sub
Is there a better way? Does a TextArea have an InsertAt() type function? I couldn't find one, but that doesn't mean it doesn't exist!