前のバージョンでは「コードをコピー→clearをクリック→コードをペースト」ができなかった。
BloggerStyle.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
width="164" height="164"
minWidth="164" minHeight="164"
showFlexChrome="true"
paddingBottom="2" paddingLeft="2" paddingRight="2" paddingTop="2"
showStatusBar="false"
title="BloggerStyle"
>
<mx:Script>
<![CDATA[
import mx.controls.CheckBox;
private static var TEMPLATE_TEXT_A:String
= '<pre class="mycodeT" onclick="toggleMyCode(this)">%name%</pre>'
+ '<pre class="mycodeB">%body%</pre>';
private static var TEMPLATE_TEXT_B:String
= '<pre class="mycodeT">%name%</pre>'
+ '<pre class="mycodeB">%body%</pre>';
private function escape(x:String):String {
x = x.replace(/&/g, '&');
x = x.replace(/</g, '<');
x = x.replace(/>/g, '>');
x = x.replace(/"/g, '"'); // "
return x;
}
private function format():String {
var name:String = escape(src_name.text);
var body:String = escape(src_body.text);
if(src_clickable.selected)
{
return TEMPLATE_TEXT_A.replace(/%name%/, name).replace(/%body%/, body);
}
return TEMPLATE_TEXT_B.replace(/%name%/, name).replace(/%body%/, body);
}
private function updateResult():void {
var text:String;
if(src_name.text != '' || src_body.text != ''){
text = format();
var cb:Clipboard = Clipboard.generalClipboard;
cb.setData(ClipboardFormats.TEXT_FORMAT, text);
}
else{
text = '';
}
if(dst != null){
dst.text = text;
}
}
private function clear():void {
src_name.text = '';
src_body.text = '';
}
]]>
</mx:Script>
<mx:TabNavigator width="100%" height="100%">
<mx:VBox label="I" width="100%" height="100%">
<mx:TextInput id="src_name" change="updateResult()"
width="100%" />
<mx:TextArea id="src_body" change="updateResult()"
width="100%" height="100%"
horizontalScrollPolicy="on" verticalScrollPolicy="on"/>
<mx:ControlBar
width="100%"
paddingBottom="2" paddingLeft="2" paddingRight="2" paddingTop="2">
<mx:CheckBox id="src_clickable" label="clickable?" click="updateResult()"/>
<mx:Spacer width="100%"/>
<mx:Button label="clear" click="clear()"/>
</mx:ControlBar>
</mx:VBox>
<mx:Canvas label="O" show="updateResult()"
width="100%" height="100%" >
<mx:TextArea id="dst"
editable="false"
width="100%" height="100%"
horizontalScrollPolicy="on" verticalScrollPolicy="on"/>
</mx:Canvas>
</mx:TabNavigator>
</mx:WindowedApplication>
0 件のコメント:
コメントを投稿