Code to display a Menu.
347693
public void postSetupGrid()
    {
        Record menu = this.getMainRecord();
        BaseListener behMenu = menu.getListener(StringSubFileFilter.class.getName());
        menu.removeListener(behMenu, true);
    }
495732
private function printMenuTree() {
		/*
		* The elements in the array are :
		*   0: Menu item name
		*   1: Minimum level or capability required.
		*   2: The URL of the item's file
		*   3: Class
		*   4: ID
		*   5: Icon for top level menu
		*/
		global $menu, $submenu;
		if ( ! is_iterable( $menu ) ) {
			return;
		}

		echo '<ul class="ul-disc">';
		foreach ( $menu as $arr1 ) {
			if ( empty( $arr1[0] ) ) {
				continue;
			}
			$menu_hook = get_plugin_page_hook( $arr1[2], null );
			if ( $menu_hook ) {
				$href = 'admin.php?page=' . $arr1[2];
			} else {
				$href = $arr1[2];
			}
			echo "<li><a href='{$href}'>{$arr1[0]}</a>";
			foreach ( $submenu as $k => $arr2 ) {
				if ( $k === $arr1[2] ) {
					echo '<ul class="ul-disc">';
					foreach ( $arr2 as $arr3 ) {
						$menu_hook = get_plugin_page_hook( $arr3[2], $k );
						if ( $menu_hook ) {
							if ( str_ends_with( $k, '.php' ) ) {
								$href = "{$k}?page={$arr3[2]}";
							} else {
								$href = "admin.php?page={$arr3[2]}";
							}
						} else {
							$href = $arr3[2];
						}
						echo "<li><a href='{$href}'>{$arr3[0]}</a>";
					}
					echo '</ul>';
					continue;
				}
			}
		}
		echo '</ul>';
	}
145633
function menu( items, nextStep ) {
    const rl = RL.createInterface( {
        input: process.stdin,
        output: process.stdout
    } );
    console.log();
    items.forEach( function ( item, idx ) {
        var out = idx < 10 ? ' ' : '';
        out += ( "" + ( 1 + idx ) + ") " ).yellow;
        out += item;
        console.log( out );
    } );
    console.log();
    rl.question( "Your choice: ", ( ans ) => {
        rl.close();
        var choice = parseInt( ans );
        if ( isNaN( ans ) || ans < 1 || ans > items.length ) {
            menu( items, nextStep );
        } else {
            console.log();
            nextStep( choice );
        }
    } );
}
417073
def generate_menu(self, ass, text, path=None, level=0):
        
        menu = self.create_menu()
        for index, sub in enumerate(sorted(ass[1], key=lambda y: y[0].fullname.lower())):
            if index != 0:
                text += "|"
            text += "- " + sub[0].fullname
            new_path = list(path)
            if level == 0:
                new_path.append(ass[0].name)
            new_path.append(sub[0].name)
            menu_item = self.menu_item(sub, new_path)
            if sub[1]:
                # If assistant has subassistants
                (sub_menu, txt) = self.generate_menu(sub, text, new_path, level=level + 1)
                menu_item.set_submenu(sub_menu)
            menu.append(menu_item)
        return menu, text
720108
private void showContextMenu(ContextMenuEvent e) {
        ContextMenu menu = view.getContextMenu();
        double xOffset = view.getContextMenuXOffset();
        double yOffset = view.getContextMenuYOffset();

        menu.show(view, e.getScreenX() + xOffset, e.getScreenY() + yOffset);
    }
629380
def show_in_menus_custom(self, request=None, current_site=None,
                             menu_instance=None, original_menu_tag=''):
        
        if not self.show_in_menus:
            return False
        if self.link_page:
            return self.link_page_is_suitable_for_display()
        return True
867290
function () {
        var self = this;

        function activateMenuItemsByValue(menu, value) {
          if (menu instanceof Menu) {
            menu.items().each(function (ctrl) {
              if (!ctrl.hasMenus()) {
                ctrl.active(ctrl.value() === value);
              }
            });
          }
        }

        function getSelectedItem(menuValues, value) {
          var selectedItem;

          if (!menuValues) {
            return;
          }

          for (var i = 0; i < menuValues.length; i++) {
            if (menuValues[i].value === value) {
              return menuValues[i];
            }

            if (menuValues[i].menu) {
              selectedItem = getSelectedItem(menuValues[i].menu, value);
              if (selectedItem) {
                return selectedItem;
              }
            }
          }
        }

        self.on('show', function (e) {
          activateMenuItemsByValue(e.control, self.value());
        });

        self.state.on('change:value', function (e) {
          var selectedItem = getSelectedItem(self.state.get('menu'), e.value);

          if (selectedItem) {
            self.text(selectedItem.text);
          } else {
            self.text(self.settings.text);
          }
        });

        return self._super();
      }
279503
public function display()
    {
        $style = new Style();
        echo PHP_EOL;

        echo $style->setText('Use    : ')
            ->color('fg', Style::COLOR_GREEN)
            ->highlight('fg')
            ->bold()
            ->get();

        echo $style->reset()
            ->setText('php  ' . $this->scriptName . ' [OPTION]...')
            ->highlight('fg')
            ->bold()
            ->get() . PHP_EOL;

        echo $style->reset()
            ->setText('OPTIONS: ')
            ->color('fg', Style::COLOR_GREEN)
            ->bold()
            ->get() . PHP_EOL;

        foreach ($this->arguments as $argument) {
            $line = '  ';

            if (! empty($argument->shortName)) {
                $line .= '-' . $argument->shortName;

                if ($argument->hasValue) {
                    $line .= ' ARG';
                }

                $line .= ',';
            }

            $line = str_pad($line, 10); // add 8 space


            if (! empty($argument->fullName)) {
                $line .= '--' . $argument->fullName;
                if ($argument->hasValue) {
                    $line .= '=ARG';
                }
            }

            $line = $style->reset()
                ->setText(str_pad($line, 40))
                ->bold()
                ->get();
            $line .= $argument->description;

            if ($argument->isMandatory) {
                $line .= $style->reset()
                    ->setText(' - MANDATORY')
                    ->color('fg', Style::COLOR_RED)
                    ->get();
            }

            echo $line, PHP_EOL;
        }

        echo PHP_EOL;
    }
1091505
function( editor, buttonName, buttonLabel, commandName, command, menugroup, menuOrder )
	{
		editor.addCommand( commandName, command );

		// If the "menu" plugin is loaded, register the menu item.
		editor.addMenuItem( commandName,
			{
				label : buttonLabel,
				command : commandName,
				group : menugroup,
				order : menuOrder
			});
	}
218044
def _showItemContextMenu(self, item, point, col):
        """"""
        menu = getattr(item, '_menu', None)
        if menu:
            settitle = getattr(item, '_set_menu_title', None)
            if settitle:
                settitle()
            # self._current_item tells callbacks what item the menu was referring to
            point = self.etw.mapToGlobal(point)
            self._current_item = item
            self.etw.clearSelection()
            self.etw.setItemSelected(item, True)
            menu.exec_(point)
        else:
            self._current_item = None
1209378
def main():
  ''''''
  arguments = docopt(__doc__, version=__version__)

  if arguments['configure'] and flag:
    configure()
  if arguments['cuisine']:
    if arguments['list']:
      cuisine('list')
    else:
      cuisine(arguments['<cuisine-id>'])
  elif arguments['surprise']:
    surprise()
  elif arguments['reviews']:
    reviews(arguments['<restaurant-id>'])
  elif arguments['search']:
    search(arguments['QUERY'])
  elif arguments['budget']:
    try:
      money = arguments['<budget>']
      money = float(money)
      budget(money)
    except:
      print 'Budget should be a number!'
  elif arguments['restaurant']:
    restaurant(arguments['<restaurant-id>'])
  else:
    print (__doc__)
830456
public void showSlideMenu() {
        synchronized (this) {
            if (!this.menuShown.getAndSet(true)) {
                final SlideMenuModel smm = getModel(Key.create(SlideMenuModel.class, this.selectedSlide));

                StackPane.setAlignment(smm.node(), Pos.CENTER);
                view().node().getChildren().add(smm.node());

                smm.node().parentProperty().addListener((observable, oldValue, newValue) -> {
                    if (newValue == null) {
                        this.menuShown.set(false);
                    }
                });
            }
        }
    }
455719
def menu text, &block
      #$log.debug "YYYY inside M: menu text #{text}  "
      m = Menu.new text, &block 
      add m
      return m
    end
843672
function(title, menu) {
			return utils.find(menu || this.getMenu(), function(val) {
				if (val.type == 'action') {
					if (val.label == title || val.name == title) {
						return val.name;
					}
				} else {
					return this.getActionNameForMenuTitle(title, val.items);
				}
			}, this);
		}
914832
public function display()
    {
        if (!$this->isVisible()) { //return nothing if it's not visible
            return "";
        }
        $content = Html::get()->link($this->getURL(), $this->getIcon() . $this->translate($this->label), $this->linkHtmlOptions);
        $submenu = "";
        $anySelected = false;
        if (count($this->items)) {
            $this->htmlOptions['class'] = (isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' ' : '') . 'm-menu-dropdown';
            $anySelected = false;
            $anyVisible = false;
            foreach ($this->items as $item) {
                /* @var $item Label */
                $submenu .= $item->display();
                $anySelected = $anySelected || $item->isSelected();
                $anyVisible = $anyVisible || $item->isVisible();
            }
            if ($anyVisible)
                $submenu = Html::get()->tag('ul', $submenu);
            else
                $submenu = "";
            if ($anySelected) {
                if (isset($this->htmlOptions['class'])) {
                    $this->htmlOptions['class'] .= ' selected';
                } else {
                    $this->htmlOptions['class'] = 'selected';
                }
            }
        }

        if ($anySelected || $this->isSelected()) {
            $this->htmlOptions['class'] = isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' selected' : 'selected';
        }

        return Html::get()->tag('li', $content . $submenu, $this->htmlOptions);
    }
60946
def submenu key, label, &block
      item = CMenuItem.new(key, label)
      @options << item
      item.action = PromptMenu.new @caller, label, &block
    end
1174368
function () {
        var self = this;

        if (self.menu) {
          self.menu.items().each(function (item) {
            if (item.hideMenu) {
              item.hideMenu();
            }
          });

          self.menu.hide();
        }
      }