简体   繁体   中英

Flex - drop down list stuck down if it opens alert dialog

I need to show a warning dialog after the users picks a certain choice in a drop down list.

It is a simple drop down list in flex (flash builder 4.6), that opens an alert dialog. When I do this, the drop down list is 'stuck' down, meaning after the choice is selected, normally the drop down list closes back up, but when I display an alert, it stays open and you have to click a choice again to close it.

drop down list mxml:

       <s:DropDownList id="typeEventDropDownList"
                        change="typeEventDropDownList_changeHandler(event)"
                        selectedIndex="0">
            <s:layout>
                <s:VerticalLayout requestedRowCount="10"/>
            </s:layout>
            <s:dataProvider>
                <s:ArrayList source="[ChooseAction,a,b,c,d,e,f,g,h,i]" />
            </s:dataProvider>
        </s:DropDownList>

drop down list handler:

protected function typeEventDropDownList_changeHandler(event:IndexChangeEvent):void
            {
                     // if this alert is called, the drop down list 'sticks' open.   if the alert is removed, it closes normally
            Alert.show("bla bla bla", "Warning",mx.controls.Alert.OK , this, null);  // does not matter if a method is called from here
                        }

I have already tried a few combinations of using the closeDropDown (and even calling OpenDropDown) before and after the alert dialog, which seems to make no difference:

         typeEventDropDownList.openDropDown();  //have tried opening and closing, closing only, before and after alert - no difference
         typeEventDropDownList.closeDropDown(true);  // have tried true and false  no difference

You can have something like

protected function typeEventDropDownList_changeHandler(event:IndexChangeEvent):void
{
callLater(DisplayAlert); 
}

protected function DisplayAlert()
{
//Display your alert here , i.e., Alert.show()
}

It worked for me.

Where are you putting the close list code? This should work:

protected function typeEventDropDownList_changeHandler(event:IndexChangeEvent):void
{
    typeEventDropDownList.closeDropDown(true);
    Alert.show("bla bla bla", "Warning",mx.controls.Alert.OK , this, null);
}

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