[英]Flex : Menu doesn't hide automatically?
我正在以這種方式創建菜單:
myMenu = Menu.createMenu( null, myMenuXMLListCollection, false );
然后顯示:
myMenu.popup( 10, 10 );
但是當我在菜單外的某個地方單擊時,菜單不會自動消失。
收聽SandBoxMouseEvent 。 沙箱根目錄上的MOUSE_UP_SOMEWHERE 。 您可以使用SystemManager獲取沙箱根目錄。 getSandboxRoot
因此,添加事件監聽器,如下所示:
systemManager.getSandBoxRoot.addEventListener(SandboxMouseEvent.MOUSE_UP_SOMEWHERE, myMouseUpHandler);
然后在事件處理程序中,只需檢查目標是否為菜單,如果不是,則隱藏菜單:
protected function myMouseUpHandler(event:SandboxMouseEvent):void{
if(event.target != myMenuInstance){
myMenuInstance.visible = false;
// or whatever other action you wish to take to hide the menu.
}
}
這是Flex ComboBox用於在單擊鼠標時隱藏下拉菜單的常規方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.