Show the selection in TextInput Control : TextInput Selection « Components « Flex

Home
Flex
1.Chart
2.Components
3.Container
4.Data Model
5.Development
6.Effects
7.Event
8.Graphics
9.Grid
10.Style
Flex » Components » TextInput SelectionScreenshots 
Show the selection in TextInput Control
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>

   
    
    
    
    
    
    
    
    
    
  
Related examples in the same category
1.Select text in TextInput controlSelect text in TextInput control
2.Display the selections of the TextInput control when you click the buttonDisplay the selections of the TextInput control when you click the button
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.