簡體   English   中英

Flex-如果打開警報對話框,則下拉列表會停留

[英]Flex - drop down list stuck down if it opens alert dialog

用戶在下拉列表中選擇某個選項后,我需要顯示一個警告對話框。

這是flex(Flash Builder 4.6)中的一個簡單下拉列表,它打開一個警報對話框。 當我這樣做時,下拉列表會“卡住”,這意味着在選擇選項后,通常下拉列表會重新關閉,但是當我顯示警報時,它將保持打開狀態,您必須再次單擊一個選項才能關閉它。

下拉列表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>

下拉列表處理程序:

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
                        }

我已經嘗試過在警報對話框之前和之后使用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

你可以有類似的東西

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

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

它為我工作。

您要在哪里放置關閉清單代碼? 這應該工作:

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