2/12/2010 3:01:22 AM
Title:
cut copy paste code
I need to do cut ,copy and paste in a textarea .what code i should write?
HELP PLEASE
2/12/2010 11:20:06 PM
try this
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Panel title="TextArea Control Example" height="75%" width="75%"
paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">
<mx:TextArea width="400" height="100">
<mx:text>
This is a multiline, editable TextArea control. If you need
a non-editable multiline control, use the Text control.
</mx:text>
</mx:TextArea>
</mx:Panel>
</mx:Application>
2/13/2010 11:16:30 AM
HI you can always cut , copy paste in textbox , make clear what exact functionality do you require?
2/14/2010 9:33:28 PM
I need to cut, copy and paste from textarea or textbox on button click event
2/15/2010 12:15:40 AM
finally i wrtten following code to do the cut copy and paste in a textarea and it is working
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mxeffects="com.adobe.ac.mxeffects.*" creationComplete="onCreationComplete()" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:TextArea id="txtedit" width="361" height="196"/>
<mx:Button id="btnpaste" label="PASTE" x="177.5" y="247" click="fnpaste()"/>
<mx:Button id="btncut" label="CUT" x="57" y="247" click="fncut()"/>
<mx:Button id="btncopy" label="COPY" x="112" y="247" click="fncopy()"/>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
public var txtfld:TextField;
import mx.core.mx_internal;
public var aa:int;
public var bb:int;
[Bindable]
private var insertionPointIndex:int;
public var a:String=new String();
use namespace mx_internal;
public function fncut():void
{
a=txtfld.selectedText;
txtfld.replaceText(aa,bb,"");
mx.controls.Alert.show(a);
btnpaste.enabled=true;
}
public function fncopy():void
{
a=txtfld.selectedText;
//txtfld.replaceText(aa,bb,"");
mx.controls.Alert.show(a);
btnpaste.enabled=true;
}
public function fnpaste():void
{
txtfld.replaceText(insertionPointIndex,insertionPointIndex,a);
}
private function onCreationComplete():void
{
txtfld = TextField(txtedit.getTextField());
txtfld.addEventListener(MouseEvent.CLICK,onTextFieldClick);
txtedit.addEventListener(TextEvent.TEXT_INPUT,onTextAreaTextInput);
txtedit.addEventListener(Event.CHANGE,onTextAreaChange);
btnpaste.enabled=false;
}
private function onTextFieldClick(event:Event):void
{
update();
}
private function onTextAreaTextInput(event:Event):void
{
update();
}
private function onTextAreaChange(event:Event):void
{
update();
}
private function update():void
{
insertionPointIndex = txtfld.caretIndex;
aa=txtedit.selectionBeginIndex;
bb=txtedit.selectionEndIndex;
}
]]>
</mx:Script>
</mx:WindowedApplication>
2/15/2010 2:13:33 AM
thanks rani, for the copy paste code