Maybe this is a well known problem that people just don’t like to talk about, or perhaps I’ve not managed to hit upon the correct search terms, but I can’t find any discussion of this issue. People must have come across this before though…
TextField’s appendText method seems to have a fairly large bug with “\r” characters.
Examples: (using a TextField called “txt”)
txt.text += "ABC\r";
txt.text += "DEF\r";
txt.text += "GHI\r";
txt.text += "JKL\r";
As expected, txt contains:
ABC
DEF
GHI
JKL
txt.appendText("ABC
");
txt.appendText("DEF
");
txt.appendText("GHI
");
txt.appendText("JKL
");
Gives the same expected result.
txt.appendText("ABC\r");
txt.appendText("DEF\r");
txt.appendText("GHI\r");
txt.appendText("JKL\r");
Gives this:
ABCDEFGHIJKL
…followed by four new lines!
txt.appendText("ABC\rDEF\r");
txt.appendText("GHI\rJKL\r");
txt.appendText("MNO\rPQR\r");
txt.appendText("STU\rVWX\r");
This gives you:
ABC
DEGHI
JKMNO
PQSTU
VWX
R
L
F
Not good.
The fun really begins when you have long strings full of "
" - your appended text starts appearing all over the place.
So I guess I’m going to need to put in a find and replace everytime I use appendText from now on, unless I’m missing something or anyone else has got any better ideas.