开发者

In actionscript 3 how can I edit a textArea after applying a styleSheet?

开发者 https://www.devze.com 2022-12-21 21:35 出处:网络
Here is a portion of my code: var styles:String = \".keyword{color: #ff0000;} .comment{color: #00ff00;}\";

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 my开发者_开发百科TextArea.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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消