DesktopTextArea.AddText behavior & doc

The documentation says:

AddText(text As String)

Adds the passed text to the current Text.

  1. What is current text and how do I define it ?
  2. Works fine to add “Vanessa”, but not to add a larger text: in that case, it goes at the end of the Text (Append…)

I wasted hours with that because I couldn’t understand the difference: same code (but larger string).

At last; I used .SelectedText (after .SelectionStart Integer) and it worked.

The current text is the text already in the textarea, as in myTextArea.Text. So, the text is added at the end of the existing text. And it tells you why to use that, too.

Or is that not what you mean?

Not always. And that is the core of the trouble.

I do not talk about speed.(Using + is slower).

It’s supposed to be always.

If it’s not behaving that way you have some code causing the conflict or there’s a huge new bug in the framework. You should review your event handlers and timers.

3 Likes

The used code:

// Reset the Cursor (to the top / nothing selected)
TA.SelectionLength = 0 // No Selected Text
TA.SelectionStart  = 0
TA.AddText href_table // A huge string (*)

I replaced it with “Vanessa” and I get Vanessa where I wanted ! Else, the href_table is added at the end of the DesktopTextArea.

No timer, no event, nothing fancy, a simple flow of code.

But yes, I can take sometimes to check in a simple project.

Looks like you trying to use AddText to insert text before any text on the DeskktopTextArea? And you were able to make Vanessa show where you wanted (not at the end of DesktopTextArea).

I’m sorry but I can only add Vanessa to the end, this on Mac 14.7.2 and Xojo2024r4.1

Local weather. Seriously, I got that. I’m in my bed, I will check tomorrowwith a simple project.