根菜单 popupmenu 或者到中间的 menu 菜单
504671
function () {
            var self = this, cur = self, last;
            do {
                // 沿着 menu，menuitem 链
                last = cur;
                cur = cur.get('parent');
            } while (cur && (cur.isMenuItem || cur.isMenu));
            return last;
        }
206933
def _popup_menu(self, icon, button, time, extended=True):
        """"""
        m = self.create_context_menu(extended)
        m.show_all()
        m.popup(parent_menu_shell=None,
                parent_menu_item=None,
                func=icon.position_menu,
                data=icon,
                button=button,
                activate_time=time)
        # need to store reference or menu will be destroyed before showing:
        self._m = m
978402
protected void openPopup(final A_CmsContextMenuItem item) {

        m_popup.add(item.getSubMenu());
        m_popup.addAutoHidePartner(item.getElement());
        m_popup.setModal(false);
        m_popup.show();

        setSubMenuPosition(item);

        if (m_isFixed) {
            m_popup.setPositionFixed();
        }
    }
1361573
public void showMenu(List<I_CmsContextMenuEntry> menuEntries) {

        if (!CmsClientCollectionUtil.isEmptyOrNull(menuEntries)) {
            // if there were entries found for the menu, create the menu
            m_menu = new CmsContextMenu(menuEntries, true, getPopup());
            // add the resize handler for the menu
            m_resizeRegistration = Window.addResizeHandler(m_menu);
            // set the menu as widget for the panel
            m_menuPanel.setWidget(0, 0, m_menu);
            if (m_menuCloseHandler != null) {
                m_menuCloseHandler.removeHandler();
            }
            if (m_popupCloseHandler != null) {
                m_popupCloseHandler.removeHandler();
            }
            // add the close handler for the menu
            m_menuCloseHandler = getPopup().addCloseHandler(new CmsContextMenuCloseHandler(m_menu));
            m_popupCloseHandler = getPopup().addCloseHandler(new CloseHandler<PopupPanel>() {

                public void onClose(CloseEvent<PopupPanel> event) {

                    closeMenu();
                }
            });
            m_popup.position();
        } else {
            m_menuPanel.setWidget(0, 0, m_noEntriesLabel);
            m_popup.position();
        }
    }
1067091
def set_popup_menu(self, menu):
        ''''''
        self.popup_menu = menu
        if menu is None:
            self.wx_popup_menu = None
        else:
            self.wx_popup_menu = menu.wx_menu()
            self.frame.Bind(wx.EVT_MENU, self.on_menu)
1165564
function toggleSubmenu(trigger, toggleFn) {
    const droplet = document.getElementById(trigger.getAttribute('aria-controls'));

    if (!droplet) { return; }

    toggleFn(droplet, (noFocus, focusTarget) => {
      const prevExpanded = droplet.getAttribute('aria-expanded');
      const wasCollapsed = !prevExpanded || prevExpanded === 'false';
      droplet.setAttribute('aria-expanded', wasCollapsed ? 'true' : 'false');

      if (focusTarget) {
        focusTarget.focus();
      } else if (!noFocus) {
        let active = queryAll('.dqpl-menuitem-selected', droplet).filter(isVisible);
        active = active.length ?
          active :
          queryAll('[role="menuitem"][tabindex="0"]', droplet).filter(isVisible);
        let focusMe = wasCollapsed ? active[0] : closest(droplet, '[aria-controls][role="menuitem"]');
        focusMe = focusMe || elements.trigger;
        if (focusMe) { focusMe.focus(); }
      }
    });
  }
652521
private void openSubMenu() {

        if (isEnabled() && hasSubMenu() && !m_subMenu.isShowing()) {
            m_overlay.closeSubMenus();

            setFocus(false);
            addStyleName("v-context-menu-item-basic-open");
            m_subMenu.openNextTo(this);
        }
    }
77966
def OnMenu(self, event):
        """"""

        __id = event.GetId()
        try:
            menuitem = event.GetEventObject().FindItemById(__id)
            selected_text = menuitem.GetItemLabel()
            self.search.SetValue(selected_text)
        except AttributeError:
            # Not called by menu
            event.Skip()
257978
def _showItemContextMenu(self, item, point, col):
        """"""
        self._startOrStopEditing()
        menu = getattr(item, '_menu', None)
        if menu:
            # self._current_item tells callbacks what item the menu was referring to
            self._current_item = item
            self.clearSelection()
            self.setItemSelected(item, True)
            menu.exec_(point)
        else:
            self._current_item = None
645052
def contextMenuEvent(self, event):
        """"""
        self.opt_menu.popup(event.globalPos())
        event.accept()
982271
def contextMenuEvent(self, event):
        """"""
        self.setCurrentIndex(self.tabBar().tabAt(event.pos()))
        if self.menu:
            self.menu.popup(event.globalPos())
236225
function setupContextMenu() {
  var enableContextMenuItem = contextMenu.Item({
    label: 'Enable For This URL',
    data: 'toggle',
    contentScript:
        "self.on('context', function(node) {" +
        "  var hasWtf = !!document.querySelector('.wtf_a');" +
        "  return !hasWtf ? 'Enable For This URL' : 'Disable For This URL';" +
        "});"
  });
  var resetSettingsContextMenuItem = contextMenu.Item({
    label: 'Reset Settings For This URL',
    data: 'reset'
  });
  var showUiContextMenuItem = contextMenu.Item({
    label: 'Show UI',
    data: 'show_ui'
  });
  var rootContextMenuItem = contextMenu.Menu({
    label: 'Tracing Framework',
    items: [
      enableContextMenuItem,
      resetSettingsContextMenuItem,
      contextMenu.Separator(),
      showUiContextMenuItem
    ],
    contentScript:
        "self.on('click', function(node, data) {" +
        "  self.postMessage(data);" +
        "});",
    onMessage: function(action) {
      switch (action) {
        case 'toggle':
          toggleInjectionForActiveTab();
          break;
        case 'reset':
          resetOptionsForActiveTab();
          break;
        case 'show_ui':
          showUi();
          break;
      }
    }
  });
}
1187227
function (_this) {
    var menuLeft;
    var menuTop;

    // 菜单位置和方向
    var position;
    var align;

    // window 窗口的宽度和高度
    var windowHeight = $window.height();
    var windowWidth = $window.width();

    // 配置参数
    var gutter = _this.options.gutter;
    var isCovered = _this.isCovered;
    var isFixed = _this.options.fixed;

    // 动画方向参数
    var transformOriginX;
    var transformOriginY;

    // 菜单的原始宽度和高度
    var menuWidth = _this.$menu.width();
    var menuHeight = _this.$menu.height();

    var $anchor = _this.$anchor;

    // 触发菜单的元素在窗口中的位置
    var anchorTmp = $anchor[0].getBoundingClientRect();
    var anchorTop = anchorTmp.top;
    var anchorLeft = anchorTmp.left;
    var anchorHeight = anchorTmp.height;
    var anchorWidth = anchorTmp.width;
    var anchorBottom = windowHeight - anchorTop - anchorHeight;
    var anchorRight = windowWidth - anchorLeft - anchorWidth;

    // 触发元素相对其拥有定位属性的父元素的位置
    var anchorOffsetTop = $anchor[0].offsetTop;
    var anchorOffsetLeft = $anchor[0].offsetLeft;

    // ===============================
    // ================= 自动判断菜单位置
    // ===============================
    if (_this.options.position === 'auto') {

      // 判断下方是否放得下菜单
      if (anchorBottom + (isCovered ? anchorHeight : 0) > menuHeight + gutter) {
        position = 'bottom';
      }

      // 判断上方是否放得下菜单
      else if (anchorTop + (isCovered ? anchorHeight : 0) > menuHeight + gutter) {
        position = 'top';
      }

      // 上下都放不下，居中显示
      else {
        position = 'center';
      }
    } else {
      position = _this.options.position;
    }

    // ===============================
    // ============== 自动判断菜单对齐方式
    // ===============================
    if (_this.options.align === 'auto') {

      // 判断右侧是否放得下菜单
      if (anchorRight + anchorWidth > menuWidth + gutter) {
        align = 'left';
      }

      // 判断左侧是否放得下菜单
      else if (anchorLeft + anchorWidth > menuWidth + gutter) {
        align = 'right';
      }

      // 左右都放不下，居中显示
      else {
        align = 'center';
      }
    } else {
      align = _this.options.align;
    }

    // ===============================
    // ==================== 设置菜单位置
    // ===============================
    if (position === 'bottom') {
      transformOriginY = '0';

      menuTop =
        (isCovered ? 0 : anchorHeight) +
        (isFixed ? anchorTop : anchorOffsetTop);

    } else if (position === 'top') {
      transformOriginY = '100%';

      menuTop =
        (isCovered ? anchorHeight : 0) +
        (isFixed ? (anchorTop - menuHeight) : (anchorOffsetTop - menuHeight));

    } else {
      transformOriginY = '50%';

      // =====================在窗口中居中
      // 显示的菜单的高度，简单菜单高度不超过窗口高度，若超过了则在菜单内部显示滚动条
      // 级联菜单内部不允许出现滚动条
      var menuHeightTemp = menuHeight;

      // 简单菜单比窗口高时，限制菜单高度
      if (!_this.isCascade) {
        if (menuHeight + gutter * 2 > windowHeight) {
          menuHeightTemp = windowHeight - gutter * 2;
          _this.$menu.height(menuHeightTemp);
        }
      }

      menuTop =
        (windowHeight - menuHeightTemp) / 2 +
        (isFixed ? 0 : (anchorOffsetTop - anchorTop));
    }

    _this.$menu.css('top', menuTop + 'px');

    // ===============================
    // ================= 设置菜单对齐方式
    // ===============================
    if (align === 'left') {
      transformOriginX = '0';

      menuLeft = isFixed ? anchorLeft : anchorOffsetLeft;

    } else if (align === 'right') {
      transformOriginX = '100%';

      menuLeft = isFixed ?
        (anchorLeft + anchorWidth - menuWidth) :
        (anchorOffsetLeft + anchorWidth - menuWidth);
    } else {
      transformOriginX = '50%';

      //=======================在窗口中居中
      // 显示的菜单的宽度，菜单宽度不能超过窗口宽度
      var menuWidthTemp = menuWidth;

      // 菜单比窗口宽，限制菜单宽度
      if (menuWidth + gutter * 2 > windowWidth) {
        menuWidthTemp = windowWidth - gutter * 2;
        _this.$menu.width(menuWidthTemp);
      }

      menuLeft =
        (windowWidth - menuWidthTemp) / 2 +
        (isFixed ? 0 : anchorOffsetLeft - anchorLeft);
    }

    _this.$menu.css('left', menuLeft + 'px');

    // 设置菜单动画方向
    _this.$menu.transformOrigin(transformOriginX + ' ' + transformOriginY);
  }
1178939
public void clickOnMenuItem(String text, boolean subMenu)
	{
		if(config.commandLogging){
			Log.d(config.commandLoggingTag, "clickOnMenuItem(\""+text+"\", "+subMenu+")");
		}
		
		clicker.clickOnMenuItem(text, subMenu);
	}
745838
def on_menu(self, event):
        ''''''
        state = self.state
        if self.popup_menu is not None:
            ret = self.popup_menu.find_selected(event)
            if ret is not None:
                ret.popup_pos = self.popup_pos
                if ret.returnkey == 'fitWindow':
                    self.fit_to_window()
                elif ret.returnkey == 'fullSize':
                    self.full_size()
                else:
                    state.out_queue.put(ret)
                return
        if self.menu is not None:
            ret = self.menu.find_selected(event)
            if ret is not None:
                state.out_queue.put(ret)
                return
647816
function (inst) {
    // 点击打开子菜单
    inst.$menu.on('click', '.mdui-menu-item', function (e) {
      var $this = $(this);
      var $target = $(e.target);

      // 禁用状态菜单不操作
      if ($this.attr('disabled') !== null) {
        return;
      }

      // 没有点击在子菜单的菜单项上时，不操作（点在了子菜单的空白区域、或分隔线上）
      if ($target.is('.mdui-menu') || $target.is('.mdui-divider')) {
        return;
      }

      // 阻止冒泡，点击菜单项时只在最后一级的 mdui-menu-item 上生效，不向上冒泡
      if (!$target.parents('.mdui-menu-item').eq(0).is($this)) {
        return;
      }

      // 当前菜单的子菜单
      var $submenu = $this.children('.mdui-menu');

      // 先关闭除当前子菜单外的所有同级子菜单
      $this.parent('.mdui-menu').children('.mdui-menu-item').each(function () {
        var $tmpSubmenu = $(this).children('.mdui-menu');
        if (
          $tmpSubmenu.length &&
          (!$submenu.length || !$tmpSubmenu.is($submenu))
        ) {
          closeSubMenu($tmpSubmenu);
        }
      });

      // 切换当前子菜单
      if ($submenu.length) {
        toggleSubMenu($submenu);
      }
    });

    if (inst.options.subMenuTrigger === 'hover') {
      // 临时存储 setTimeout 对象
      var timeout;

      var timeoutOpen;
      var timeoutClose;

      inst.$menu.on('mouseover mouseout', '.mdui-menu-item', function (e) {
        var $this = $(this);
        var eventType = e.type;
        var $relatedTarget = $(e.relatedTarget);

        // 禁用状态的菜单不操作
        if ($this.attr('disabled') !== null) {
          return;
        }

        // 用 mouseover 模拟 mouseenter
        if (eventType === 'mouseover') {
          if (!$this.is($relatedTarget) && $.contains($this[0], $relatedTarget[0])) {
            return;
          }
        }

        // 用 mouseout 模拟 mouseleave
        else if (eventType === 'mouseout') {
          if ($this.is($relatedTarget) || $.contains($this[0], $relatedTarget[0])) {
            return;
          }
        }

        // 当前菜单项下的子菜单，未必存在
        var $submenu = $this.children('.mdui-menu');

        // 鼠标移入菜单项时，显示菜单项下的子菜单
        if (eventType === 'mouseover') {
          if ($submenu.length) {

            // 当前子菜单准备打开时，如果当前子菜单正准备着关闭，不用再关闭了
            var tmpClose = $submenu.data('timeoutClose.mdui.menu');
            if (tmpClose) {
              clearTimeout(tmpClose);
            }

            // 如果当前子菜单已经打开，不操作
            if ($submenu.hasClass('mdui-menu-open')) {
              return;
            }

            // 当前子菜单准备打开时，其他准备打开的子菜单不用再打开了
            clearTimeout(timeoutOpen);

            // 准备打开当前子菜单
            timeout = timeoutOpen = setTimeout(function () {
              openSubMenu($submenu);
            }, inst.options.subMenuDelay);

            $submenu.data('timeoutOpen.mdui.menu', timeout);
          }
        }

        // 鼠标移出菜单项时，关闭菜单项下的子菜单
        else if (eventType === 'mouseout') {
          if ($submenu.length) {

            // 鼠标移出菜单项时，如果当前菜单项下的子菜单正准备打开，不用再打开了
            var tmpOpen = $submenu.data('timeoutOpen.mdui.menu');
            if (tmpOpen) {
              clearTimeout(tmpOpen);
            }

            // 准备关闭当前子菜单
            timeout = timeoutClose = setTimeout(function () {
              closeSubMenu($submenu);
            }, inst.options.subMenuDelay);

            $submenu.data('timeoutClose.mdui.menu', timeout);
          }
        }
      });
    }
  }
1154535
function () {
        var self = this, settings = self.settings;

        var textStyle = settings.textStyle;
        if (typeof textStyle == "function") {
          textStyle = textStyle.call(this);
        }

        if (textStyle) {
          var textElm = self.getEl('text');
          if (textElm) {
            textElm.setAttribute('style', textStyle);
          }
        }

        self.on('mouseenter click', function (e) {
          if (e.control === self) {
            if (!settings.menu && e.type === 'click') {
              self.fire('select');

              // Edge will crash if you stress it see #2660
              Delay.requestAnimationFrame(function () {
                self.parent().hideAll();
              });
            } else {
              self.showMenu();

              if (e.aria) {
                self.menu.focus(true);
              }
            }
          }
        });

        self._super();

        return self;
      }