views:

107

answers:

1

Here is a portion of my code:

var styles:String = ".keyword{color: #ff0000;} .comment{color: #00ff00;}";
var myStyleSheet:StyleSheet = new StyleSheet();
myStyleSheet.parseCSS(styles);

myTextArea.htmlText = '<span class = "keyword"> red </span> uncolored <span class = "comment"> green text</span>';

Everything is fine till this point, i can edit my text, of course everything is showed in black, and the html-tags are ignored. But when I put this code in myTextArea.styleSheet = myStyleSheet; my text will be colored as i want it to be, but the textArea will become uneditable (no blinking pointer, no reaction on keyboard press).

After each keyboard-press (or if the time between two key-presses is bigger than x milliseconds ) i will re-render the textArea.text and append the <span class = "keyword"> where needed </span> tags and put it into the textArea.htmlText, but can't seem to figure it out how to do it when style is applied.

+1  A: 

Sadly enough css and text input are incompatible. The only workaround is to use TextFormat instead. Sorry for being disappointing...

Theo.T
Yes, its sad, that they are incompatible. I'll try to create a "hacked" textArea by extending the base one, so every time the user hits a key, the style will be removed, the key will be inserted, the text will be parsed again to insert the html tags, that will be set into the htmlText of the textArea and the style will be reapplied. There are only 2 things that I'm not sure of: 1. How can I display the blinking pointer at the caridge, and 2. speed. The other idea was to put 2 textfields one on another, I edit the one on the top witch is invisible and display the text in the textfield above.
Biroka