Copy Spark TextArea Text to another Spark TextArea

115 Views Asked by At

How can we copy one spark TextArea to another spark textarea while keeping the formatting. I can retrieve the text but how i can keep the format.

What I am trying achieve is I have two spark text areas , users types in 1 with styles like (bold, italic , underline). Now when user click some additional keys like Ctrl+J or some other keys I want the text in source TextArea to another textarea while keeping the formatting applied.

Thanks in advance for help on this.

2

There are 2 best solutions below

0
Anton On BEST ANSWER

Try someting like this

        var tff:TextFlow = textArea1.textFlow.deepCopy() as TextFlow;
        textArea2.textFlow = tff;
5
Anton On

If your destination text area is an inline itemrenderer in a Datagrid you can use

        var tff:TextFlow = textArea1.textFlow.deepCopy() as TextFlow;
        var obj:Object = {};
        obj.textFlow = tff;
        dataGrid.dataProvider = new ArrayCollection([obj]);

<s:DataGrid id="dataGrid" x="500" width="1000" height="500">
    <s:itemRenderer>
        <fx:Component>
            <s:GridItemRenderer>
                <s:TextArea id="textArea2"
                            textFlow="{data.textFlow}"
                        />
            </s:GridItemRenderer>
        </fx:Component>
    </s:itemRenderer>
</s:DataGrid>