例如,假设我有3个RichEditableText对象,我希望能够一起突出显示它们:
<s:RichEditableText id="obj_one" width="100%" text="Click and start dragging the highlight here..." selectable="true" editable="false" fontSize="9" />
<s:RichEditableText id="obj_two" width="100%" text="Continue dragging the highlight through this one" selectable="true" editable="false" fontSize="9" />
<s:RichEditableText id="obj_three" width="100%" text="and keep going and finish highlighting them all right here" selectable="true" editable="false" fontSize="9" />有没有可能让这三个都突出显示,这样某人就可以一次复制所有三个,然后在某个地方跳过所有的文本?
谢谢!
编辑:我要澄清的是,它们会这样的原因是因为它们在itemRenderer中,所以在列表中的每一行中,它们都是自己的对象。不过,如果文本可以被高亮显示和复制,就像所有的文本都在一起一样,那就太好了。
想象一下,终端用户期望能够拖动高亮显示标准html文档中的任何其他文本以粘贴到其他地方的方式。
发布于 2011-08-15 21:33:33
多亏了Text Layout Framework,你现在可以对文本做任何你想做的事情。但有时它的实现可能会令人望而生畏。
我有两个解决方案给你。根据您需要的控制级别,有简单的控制和困难的控制。
简单的方法
对于大多数用例,这个解决方案应该做得很好。我假设你想以一种类似段落的方式显示这些文本。在这种情况下,您可以只使用一个RichEditableText并使用textFlow属性而不是text,如下所示:
MXML
<s:RichEditableText id="textBox" top="100" paragraphSpaceAfter="15" />作为
textBox.textFlow = TextFlowUtil.importFromString(
"<p>Click and start dragging the highlight here...</p>" +
"<p>Continue dragging the highlight through this one</p>" +
"<p>and keep going and finish highlighting them all right here</p>"
);就这样。我使用paragraphSpaceAfter样式在段落之间添加了一些间距。您还可以为任何特定段落添加样式,以便更精确地控制它们的位置。
hard way
如果您确实需要非常具体的控件(例如,如果三个文本框必须位于三个完全独立的位置),那么您可以这样做:
MXML
<mx:UIComponent id="obj_one" left="0" top="0" width="300" height="20"/>
<mx:UIComponent id="obj_two" left="50" top="30" width="300" height="20" />
<mx:UIComponent id="obj_three" left="100" top="60" width="200" height="40" />作为
//create the TextFlow object
var text:TextFlow = TextFlowUtil.importFromString(
"<p>Click and start dragging the highlight here...</p>" +
"<p>Continue dragging the highlight through this one</p>" +
"<p>and keep going and finish highlighting them all right here</p>"
);
//make the text selectable
text.interactionManager = new SelectionManager();
//make all three of the area's control the same TextFlow object
text.flowComposer.addController(
new ContainerController(obj_one, obj_one.width, obj_one.height));
text.flowComposer.addController(
new ContainerController(obj_two, obj_two.width, obj_two.height));
text.flowComposer.addController(
new ContainerController(obj_three, obj_three.width, obj_three.height));
//once the 3 controllers are assigned, recalculate the composition
text.flowComposer.updateAllControllers();正如你所看到的,我没有使用RichEditableText,因为它已经使用了自己的一个flowcomposer和interactionmanager,这将与我正在分配的那些相冲突。现在,您可以根据需要定位这三个容器并调整其大小。
但请记住:大多数用例都可以通过简单的解决方案上的一些样式来解决。(我在这里用作示例的MXML实际上非常简单,以证明这种方法是合理的,但我必须以一种简单的方式传达这个想法)
发布于 2011-08-15 08:50:17
只需在您的RichEditableText中添加一个带背景颜色的样式即可。并将来自每个组件的数据保存在ArrayCollection对象中。你可以在你需要的时候得到它。
var mydata:ArrayCollection = new ArrayCollection();
mydata.addItem({value:obj_one.text});
mydata.addItem({value:obj_two.text});
mydata.addItem({value:obj_three.text});
OtherTextarea.text = mydata.getItemAt(0).value + " " .... etchttps://stackoverflow.com/questions/7060731
复制相似问题