protected int findActiveMenuItemIndex(MenuSelectionManager manager, MenuElement[] path) {

		int popupIndexdex = getLeafPopupIndex(path);
		if (popupIndexdex == -1) {
			return -1; // not sure if this can happen
		}

		if (popupIndexdex == path.length - 1) {
			// last item is the popup--no selected menu item
			return -1;
		}

		MenuElement activeItem = path[path.length - 1];
		JPopupMenu popup = (JPopupMenu) path[popupIndexdex];
		int count = 0;
		int n = popup.getComponentCount();
		for (int i = 0; i < n; i++) {
			Component c = popup.getComponent(i);
			if (isValidItem(c)) {
				if (activeItem == c) {
					return count;
				}
				count++;
			}

		}
		return -1;
	}
The work method of this handler.  This method will only be called when a menu or popup
menu is open.

@param manager the active menu selection manager
@param path the active menu path
Ghidra/Framework/Docking/src/main/java/docking/menu/keys/MenuKeyHandler.java