Prevent copying style from one flex textArea to another
If you have two text areas with different styles (fontFamily, weight, color etc) and you copy text from one to the other it also copies the style from the originating text area. Is there any slick w开发者_StackOverfloway to prevent that?
Here is a sample of code that will illustrate the problem. Type some text in the top box and some text in the bottom, then copy some characters from the top box to the bottom. I'm not using htmltext.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:VBox width="100%" height="100%">
<mx:TextArea id="source" width="100%" fontWeight="bold" fontSize="20" height="50" />
<mx:TextArea id="dest" width="100%" height="50" />
</mx:VBox>
</mx:Application>
Here's a horribly dirty hack that gets it done:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
>
<mx:Script>
<![CDATA[
public function reformat():void
{
var hold:String = two.text
two.text = ""
two.htmlText = hold
}
]]>
</mx:Script>
<mx:VBox width="100%" height="100%" >
<mx:Button click="bonk()" />
<mx:TextArea fontWeight="bold" id="one" width="100%" height="100%" />
<mx:TextArea fontWeight="normal" id="two" width="100%" height="100%" change="reformat()" />
</mx:VBox>
</mx:Application>
Can you show a code example?
My first guess is that you are setting the htmlText
property of the first text area, and your colours and styles are via HTML. Are you copying the html tags with your copy? You might need to override the text
or htmlText
setter and strip out the tags (or change them).
I'm not even sure a copy/paste of a textarea will copy the HTML inside. Seems plausible though.
精彩评论