3 Replies Latest reply on Oct 10, 2009 9:07 PM by Flex harUI

    PopUpMenuButton itemClick setFocus() bug

    timo888 Level 1

      I have a custom ActionScript class extending HBox which encapsulates a TextInput and a PopUpMenuButton.


      In the PopUpMenuButton's itemClick handler, I attempt to set focus on the TextInput (see snippet below).


      private var mytextinput:TextInput = new TextInput;
      private var mybutton:PopUpMenuButton = new PopUpMenuButton;


      // mybutton's itemClick handler

      private function onCharSelected(e:MenuEvent):void {              
          doInsert( e.item.data.toString(), mytextinput);   // inserts a character into the TextInput

              // following statement fails if an item in the popup menu is clicked

            // but succeeds if the PopUpMenuButton's label-button is clicked


      The problem manifests itself at line 718 of FocusManager.as


      718     // Restore focus to the last control that had it if there was one.
          if (_lastFocus)   // _lastFocus is PopUpMenuButton but it should be TextInput



      I think the PopUpMenuButton's encapsulated menu's focusOutHandler is restoring focus to the PopUpMenuButton control after the focus has been set by my code to the TextInput