简体   繁体   中英

Flex 3 - Focus In/Out from TextInput

I'm trying to implement Focus In/Out from a TextInput in Flex 3. I'm using a controller to process all components events and my idea is to have a switch statement to "forward" to the appropriate method, depending on the target. My TextInput has the id "contactInput", however, the event target has something like "MainView0.topContainer.contactInput.UITextField8". Where do this UITextField8 come from? Can't I select just by "contactInput"? This is my code, on the application I define the focusIn/focusOut for all events:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                xmlns:ui="ui.*"
                xmlns:ws="ui.presenters.*"
                xmlns:components="ui.components.*"
                width="255" height="310" minWidth="255" minHeight="310"
                creationComplete="controller.init(event)"                       
                styleName="application" 
                        applicationComplete="controller.init(event)"
                        focusIn="controller.focusIn(event)"
                focusOut="controller.focusOut(event)"

My controller code:

 public function focusIn(event:FocusEvent):void {                   
        Alert.show("focus in -> target: " + event.target);

        switch (event.target) {
            case view.contactInput:             
                onContactInputFocusIn();
                break;
        }
    }

     public function focusOut(event:Event):void {
        Alert.show("focus out -> target: " + event.target);

        switch (event.target) {

            case view.contactInput:
                onContactInputFocusOut();
                break;          
        }

is there any thing wrong in this code? i am just confused.

Try to put the Alert.show function between case and onContactInputFocusOut() function. put the Alert.show in both the function and then check for that whether it came into the case statement or not...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM