如何检查菜单是否显示

时间:2010-08-30 14:08:21

标签: flex

我创建了一个菜单:

menu = Menu.createMenu(parent, get_entries());
                    menu.labelField = "@label";
                    ...
        menu.show(position.x, position.y);

如何检查菜单是否仍然显示?

1 个答案:

答案 0 :(得分:0)

收听menu的{​​{3}}事件;隐藏菜单或子菜单时调度它。在事件监听器内部,检查是否event.target == event.currentTarget。如果它们相等,则意味着菜单只是隐藏 - 否则意味着菜单仍然可见,但其中一个子菜单只是隐藏。

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