Skip to main content
Inspiring
October 10, 2009
Answered

Detecting Line Breaks in htmlText

  • October 10, 2009
  • 2 replies
  • 1319 views

I know you can identify line breaks when working with text files by checking the character equivalent, but is this possible to do with htmlText?

I am making a text editor for my client and I am using the textArea component as the input field with the data stored in an XML. All's well, except for the line break--the textArea is rendered as htmlText so that the client will be able to see the changes made instantly. By default, it works, but the spacing is all screwed up (indents, double-spaces at times), so I decided to condense the whitespace. With this on, it gets rid of the spacing issues since the html is being rendered exactly as coded. The thing is, hitting enter in the textArea does not add <br /> to the htmlText code.

Do i need to overwrite the Enter key with a custom function that inserts a ine break when using the textArea, or is there a way to detect and convert these line breaks in htmlText?

This topic has been closed for replies.
Correct answer kglad

don't you see </P><P.. when the enter key is used?

2 replies

Kasper Mejenborg Sørensen
Participant
October 10, 2009

Well.. I'm not sure i understand the problem..

As i understand you problem is, you need the textArea to input a '<br />' when you hit Enter?

Before you "save" the text in the textArea, convert all "\n\r" to "<br />".

Inspiring
October 10, 2009

@kasper sørensen

looking for \n, \t, would work for text, but not for htmlText. You won't find it in the string, and the whole time I was looking to do that. While br is htmlText's line break, flash generates <p> instead, which also allows a line break. I didn't realize that because I also took out p tags when I stripped the text of unecessary tags.

Thanks to kglad for making me realize that.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
October 10, 2009

don't you see </P><P.. when the enter key is used?

Inspiring
October 10, 2009

Oh, yeah! Another one to the dumb list. I stripped the p tags along with

theautomatically generated tags that I thought were unnecessary and just

bloating the data file (face, letterspacing, etc). I guess I oversimplified

the html data and it slipped my mind that p's around for htmlText line

breaking, so I kept looking for \n, brs, etc.

It's almost amusing to find myself getting stuck every now and then over the

smallest of problems with carelessness as the culprit. Thank you for

knocking some sense into my tired head. I think I need to get some rest and

fresh air.

kglad
Community Expert
Community Expert
October 10, 2009

you're welcome.

(and i thought i've made every error possible with flash and then yesterday i found a new one:  i wrote a function and when testing i got an "expect a right paranthesis before colon" error message.  it takes me several minutes of staring at the line of code cited to find i worte my whateverF() function like:

whateverF(e:Event){

blahblahblah

}

and forgot to prefix my function name with "function".  it seems there's no end to stupid mistakes, at least, for me.