无法在Flex RichEditableText flowlayout </tab>中插入<tab>

时间:2014-06-27 16:39:14

标签: flex tabs richeditabletext

我对此代码有一些问题:

<s:RichEditableText id="ta" width="100%" height="200" selectable="true" editable="true"/>

<fx:Script>
    <![CDATA[
var str:String = "some text<tab/>with tab";
ta.textFlow = TextConverter.importToFlow(str, TextConverter.TEXT_FIELD_HTML_FORMAT);
]]>
</fx:Script>

运行文本时显示没有空格:

“some textwith tab”


解决

我最终找到了解决方案:

var config:Configuration = Configuration(ta.textFlow.configuration);
var format:TextLayoutFormat = new TextLayoutFormat();
format.whiteSpaceCollapse = WhiteSpaceCollapse.PRESERVE;
config.textFlowInitialFormat = format;
ta.textFlow = TextConverter.importToFlow(str, TextConverter.TEXT_FIELD_HTML_FORMAT,config);

1 个答案:

答案 0 :(得分:1)

Flex的“文本字段HTML格式”仅支持subset个HTML标记:

anchor <a>
bold <b>
break <br>
font <font>
image <img>
italic <i>
list item <li>
paragraph <p>
text format <textformat>

如果您将<tab />替换为示例字符串中的/t,则会获得更好的结果。