Insert text at cursor in a TLF-based Flex Spark RichEditableText?
I want to programmatically insert formatted text at the current curso开发者_StackOverflow中文版r position in a Flex 4 (Spark) RichEditableText control. I could just modify the .text property.... But that doesn't allow me to insert formatted text. So I believe I need to interact with either .textFlow or .textFlow.interactionManager somehow? However, TLF is quite complex and I can't find a simple way to do what I want.
This seems to do it. It's a lot of work though. Not sure how I feel about all the added complexity of the new text layout framework in Flash.
var txt:RichEditableText;
var html:String = "<b>some <i>rich</i> text</b>";
var mgr:EditManager = txt.textFlow.interactionManager as EditManager;
var flow:TextFlow = TextConverter.importToFlow(html, TextConverter.TEXT_FIELD_HTML_FORMAT);
mgr.pasteTextScrap(new TextScrap(flow));
i used your coding . it is working fine but it is creating new p tag and new line. how do avoid new p tag or new line.
精彩评论