views:

10

answers:

1

In this code I'm creating a new window when I click the button. In the new window are TextInput and DropDownList components. When the new window opens, clicking the DropDownList does nothing - you have to click it a second time round to get it to open. However, click into the TextInput field first and then try opening the DropDownList works no problem.

Any reason why this is happening? Is this a bug or something I'm doing wrong? The issue occurs with Flex 4.1 and Flex Hero (Sept 2010 release).

Below is the code, or download the FXP file here.

// DropDownTest.mxml (application)
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       width="400" height="300">
    <fx:Script>
        <![CDATA[
            private function newWindow():void
            {
                this.close();

                var w:MyWindow = new MyWindow();
                w.open();
            }
        ]]>
    </fx:Script>
    <s:Button label="New Window" click="newWindow()"/>
</s:WindowedApplication>

// MyWindow.mxml (component)
<?xml version="1.0" encoding="utf-8"?>
<s:Window xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:s="library://ns.adobe.com/flex/spark" 
            xmlns:mx="library://ns.adobe.com/flex/mx"
            width="400" height="300">
     <s:TextInput/>
     <s:DropDownList y="30"/>
</s:Window>
A: 

Turns out this is a bug. Adobe suggested calling "setFocus()" after "open()" and it worked. See here for further details: http://forums.adobe.com/message/3241460#3241460

Reado