Flex中如何让TextInput被选中文本保持选中状态而不管控件是否获得焦点的例子

下面是完整代码(或点击这里察看):

下面是main.mxml:

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/04/30/always-displaying-the-selected-text-in-a-textinput-in-flex/ -->
<mx:Application name="TextInput_getTextField_alwaysShowSelection_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">
 
    <mx:Script>
        <![CDATA[
            import mx.core.UITextField;
            import mx.controls.TextInput;
 
            private function init(evt:Event):void {
                var ti:TextInput = evt.currentTarget as TextInput;
                var tf:UITextField = ti.mx_internal::getTextField();
                tf.alwaysShowSelection = true;
            }
        ]]>
    </mx:Script>
 
    <mx:TextInput id="textInput"
            text="The quick brown fox jumps over the lazy dog."
            selectionBeginIndex="4" selectionEndIndex="9"
            initialize="init(event);" />
    <mx:Button label="Submit" />
 
</mx:Application>

 

本文转自:http://blog.minidx.com/2009/08/27/2870.html

你可能感兴趣的:(function,Flex,application,import,button,encoding)