Mega Code Archive

 
Categories / Flex / Components
 

Show the selection in TextInput Control

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">   <mx:Script>            import mx.controls.Alert;       private function showSelectedText():void       {         var beginIndex:int = myInput.selectionBeginIndex;         var endIndex:int = myInput.selectionEndIndex;         var selectedText:String = myInput.text.substring(beginIndex, endIndex);         myInput.setFocus();         myInput.selectionBeginIndex = beginIndex;         myInput.selectionEndIndex = endIndex;         Alert.show(selectedText, "Selected Text");       }             </mx:Script>   <mx:HBox>     <mx:Label text="Enter some text and select them:"/>     <mx:TextInput id="myInput"/>     <mx:Button label="Show selected text" click="showSelectedText()"/>   </mx:HBox> </mx:Application>