Just use the TextArea property
selectionActivePosition
Here is a working example .
// EDIT
To insert a new line into a text field, use String functions such as substr () and length (). After pasting, you must change the current position of your cursor by adding the length of the pasted row.
EDIT //
Here is my code:
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Script> <![CDATA[ protected function onBtnInsert(event:MouseEvent):void { var str:String = "[new text]"; var pos:int = taMain.selectionActivePosition; if (pos != -1) { taMain.text = taMain.text.substr(0, pos) + str + taMain.text.substr(pos, taMain.text.length - pos); taMain.selectRange(pos + str.length, pos + str.length); } } ]]> </fx:Script> <s:VGroup x="20" y="20"> <s:TextArea id="taMain" width="200" height="150" text="I want to write something in text area with keyboard(built in keyboard) and want to add something other from the keyboard made by me at the current cursor position."/> <s:HGroup verticalAlign="bottom"> <s:Button label="Get Pos" click="{laPos.text = taMain.selectionActivePosition.toString()}"/> <s:Label text="Current position: "/> <s:Label id="laPos"/> </s:HGroup> <s:Button label="Insert text" click="onBtnInsert(event)"/> </s:VGroup> </s:Application>
Anton source share