views:

416

answers:

2

Hi all,

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 scenerio is I am typing text in the text(source). If I go to popup button & click any item. Now my focus move to the popup button. And I am not able to type in the text as the focus is lost. I need to set the focus back to the text(source) after popupbutton item selection. So that I can continue typing. in my case I need to click gain in the text & then I am able to type.

A: 
source.setFocus()
Amarghosh
gauravFlex
where are you calling `source.setFocus()` from? Do it from the close event handler of the popup button
Amarghosh
A: 

You will need to add a handler for the change event of the pop up button that sets the focus to your text box.

This will be something like this:

this.focusManager.setFocus(source);

or in your example:

<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}" 
                change="{this.focusManager.setFocus(source)}"
                height="19" toolTip="Edit at segment"/>
    </mx:VBox>
</mx:HBox>
robmcm
The change event may not be right for a popup button, but it would work for a combobox. You may need to change what event triggers the setFocus to suit your needs.
robmcm