简体   繁体   English

Flex-如果打开警报对话框,则下拉列表会停留

[英]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. 这是flex(Flash Builder 4.6)中的一个简单下拉列表,它打开一个警报对话框。 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: 下拉列表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: 我已经尝试过在警报对话框之前和之后使用closeDropDown(甚至调用OpenDropDown)的几种组合,这似乎没有什么区别:

         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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM