R – flex regain lost focus

actionscript-3airapache-flex

I have a custom component with textbox & a poup button
as

<mx:HBox>   
    <mx:Text id="source" height="100%" width="40%" data="my text" />
    <mx:VBox backgroundAlpha="0" height="100%" borderThickness="0"> 
        <mx:PopUpButton enabled="true" id="editButton"  width="40" icon="@Embed('assets/images/Legends/editIcon.png')" 
            initialize="popUpButton_initialize()" 
            popUp="{actionMenuEdit}" 
            height="19" toolTip="Edit at segment"/>
    </mx:VBox>
</mx:HBox>

I am using this custom component as the itemEditor for the datagrid

I have a problem with focus. I need to set focus to the text after popup buttton itemclick
The scenario is that I am typing text in the source text. If I go to popup button and click any item, the focus moves to the popup button, and I am unable to type in the text as the focus is lost.

I need to set the focus back to the source code after pop-up-button item-selection so that I can continue typing.
At the moment I need to click gain in the text and then I am able to type.

Best Answer

source.setFocus()
Related Topic