示例#1
0
  public boolean performItemAction(MenuItem item, int flags) {
    MenuItemImpl itemImpl = (MenuItemImpl) item;

    if (itemImpl == null || !itemImpl.isEnabled()) {
      return false;
    }

    boolean invoked = itemImpl.invoke();

    if (itemImpl.hasCollapsibleActionView()) {
      invoked |= itemImpl.expandActionView();
      if (invoked) close(true);
    } else if (item.hasSubMenu()) {
      close(false);

      final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
      final ActionProvider provider = item.getActionProvider();
      if (provider != null && provider.hasSubMenu()) {
        provider.onPrepareSubMenu(subMenu);
      }
      invoked |= dispatchSubMenuSelected(subMenu);
      if (!invoked) close(true);
    } else {
      if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
        close(true);
      }
    }

    return invoked;
  }
示例#2
0
  public boolean performShortcut(int keyCode, KeyEvent event, int flags) {
    final MenuItemImpl item = findItemWithShortcutForKey(keyCode, event);

    boolean handled = false;

    if (item != null) {
      handled = performItemAction(item, flags);
    }

    if ((flags & FLAG_ALWAYS_PERFORM_CLOSE) != 0) {
      close(true);
    }

    return handled;
  }
示例#3
0
 /** * {@inheritDoc} */
 public void close() {
   close(true);
 }