开发者

How to check if a menu is displayed

开发者 https://www.devze.com 2023-01-14 04:53 出处:网络
I create a menu with this: menu = Menu.createMenu(p开发者_如何学JAVAarent, get_entries()); menu.labelField = \"@label\";

I create a menu with this:

menu = Menu.createMenu(p开发者_如何学JAVAarent, get_entries());
                    menu.labelField = "@label";
                    ...
        menu.show(position.x, position.y);

How can to check if the menu is still displayed?


Listen to the menuHide event of the menu; it is dispatched when the menu or a submenu is hidden. Inside the event listener, check if event.target == event.currentTarget. If they are equal, it means that the menu was just hidden - otherwise it means that the menu is still visible, but one of its submenus were just hidden.

menu.addEventListener(MeuEvent.MENU_HIDE, onHide);
private function onHide(e:Event):void
{
  if(e.target == e.currentTarget)
    trace("The main menu was just hidden");
  else
    trace("main menu is still visible, the submenu " 
            + e.target + " was just hidden");
}
0

精彩评论

暂无评论...
验证码 换一张
取 消