Skip to content
Pauta5.0.0

Menus

Two surfaces show the same rows: the menu bar, a browsable map of every command, and right-click menus, what can be done with the thing under the pointer. Both are built from the command registry, so a row’s title, icon, chord and enabled state come from the command and never drift from the palette or the toolbar. Reference: Editora’s ui/MainMenuBar.java (menu bar), ui/ContextMenuDismissal.java, ui/LazyContextMenu.java, ui/RowContextMenu.java and ui/TabContextMenu.java (right-click menus), and the .menu-item and .context-menu rules in app.css.

Rules on this page 17
IDLevelRule
Look and feel
MENU-14MUST
Every row of every menu the app draws carries an icon that depicts it. A command row wears its command’s glyph; a row that names a thing rather than an action (a recent file, a branch, a project) wears that thing’s icon; a submenu wears its family’s. Only a check or radio row goes without, because its mark fills the icon column. Where the icon set has no glyph that depicts a command, the app adds one (a Material 24 dp path, or a line glyph in the kit’s style) instead of leaving the row blank or borrowing another command’s.
MENU-15MUST
Every menu row whose command has a chord in the active keymap shows it, in right-click menus and drop-downs as in the menu bar: right-aligned in the menu’s chord column, Inter 11 px in -state-key. An unbound command leaves the cell empty, never a wrong chord, and a keymap switch rewrites every cell.
MENU-16MUST
Every menu draws its titles in Inter 14 px regular and its chords in Inter 11 px at the default zoom, scaled by the UI zoom (WIN-09), whatever node it was opened from: the size is pinned on .context-menu and its rows’ labels from one value the zoom sets, never inherited from the node.
The menu bar
MENU-01MUST
Every menu-bar item is a command from the registry, with its title (KBD-03), its chord from the active keymap and its enabled state from the command’s gate. The bar assembles and refreshes; it holds no behavior of its own.
MENU-02MUST
Menu-bar rows use no KeyCombination accelerators. In the in-window bar each row is a CustomMenuItem laying out icon, title, spacer and chord. On the macOS system menu bar (useSystemMenuBar) the chord is appended to the title and rows carry no icon.
MENU-03SHOULD
Enablement is re-read every time a menu opens, and titles and chords on a keymap or locale change.
MENU-04SHOULD
Simple mode shows a shorter menu, rebuilt only when the mode actually changes.
Right-click menus
MENU-05MUST
Every list row, tree row, tab, editor and read-only console has a right-click menu with the actions for that thing, each one a command.
MENU-06MUST
One right-click menu at a time: a right-click while a menu is open replaces it, and the first one closes before the second shows.
MENU-07MUST
A press anywhere outside a right-click menu closes it, including inside the control the menu was opened on. The press is not consumed: a click in a list still selects the row, and a right-click on another row opens that row’s menu straight away. Drop-downs opened by a plain click (menu buttons, choice boxes, the menu bar) keep the stock behavior, and a menu that turned auto-hide off is left alone.
MENU-08MUST
Escape closes a right-click menu and focus goes back where it was. In a terminal the Escape does not reach the shell.
MENU-09MUST
The Menu key and Shift+F10 open the selected row’s menu, scrolled into view first, so every row action a mouse can reach the keyboard can too.
MENU-17SHOULD
The in-window menu bar is reachable from the keyboard in every keymap. JavaFX opens its first menu on F10 (Ctrl+F10 on macOS) and on a lone Alt; a keymap that binds that key to something else binds a command that focuses the menu bar instead.
MENU-10SHOULD
A right-click selects first. In an editor, a right-click outside every selection moves the caret to the click (so Paste lands there); inside a selection it keeps carets and selections (so Cut and Copy act on what was clicked). From the keyboard the target is the caret. In a list, the menu is the clicked row’s.
MENU-11SHOULD
A menu attached to something that exists once per open file is built when first shown, and set up for each showing: an onShowing handler sets the labels, enablement and visibility for this showing, then collapses the separators.
MENU-12SHOULD
A destructive row carries the danger class. The action follows the window shell rule: it asks first with a button that names it, or is undoable.
MENU-13MAY
In a terminal view, a program that grabbed the mouse owns the right-click; Shift+right-click always opens the menu, and the keyboard request is never contested.

Both surfaces draw their rows the same way. Absolute pixels are deliberate: a popup inherits the font of the node it was opened from, and em would resolve against a file tree’s or an 18 px toolbar’s size (Editora’s toolbar menu once rendered a third larger than every other menu in the app).

PropertyValueReference
FontInter 14 px, regular, in every row and label.context-menu, .context-menu .menu-item .label in app.css; MainMenuBar.UI_FONT_SIZE
Row34 px high: padding 8 × 12, the same in every theme.menu-item { -fx-padding: 8px 12px }
Icon column22 px, filled on every row: a command row’s glyph, or a check row’s tick; 8 px to the titleMainMenuBar.ICON_COLUMN, rowContent
IconThe command’s glyph, the same one as on the toolbar and in the palette (Save is the same floppy everywhere), filled -color-fg-mutedIcons, MenuBarIcons, .toolbar-icon
TitleInter 14 px, -color-fg-default.menu-item-title
ChordRight-aligned in its own column, Inter 11 px, in the keyboard color (-state-key, brace periwinkle); at least 18 px from the title column; in every menu, right-click menus included.menu-item-chord, alignChordColumns
Submenu rowLaid out like a command row, with an invisible chord as wide as the menu’s widest, so the arrow lands at the right edgenestedMenu, .menu-submenu
CardRadius 8; shadow rgba(27,30,42,0.28), radius 16, offset Y 16.context-menu
Danger itemText in -color-danger-fg.menu-item.danger
Disabled itemThe theme’s dimmed label, and the icon dimmed with itTermina’s .menu-item:disabled .menu-icon
SeparatorsNever two in a row and none at either end: when items hide, their orphaned separators hide tooLazyContextMenu.collapseSeparators, Torrenta’s MenuSeparators

The shadow’s offset is not cosmetic. A menu is a native window sized to its root including the effect, so a shadow that reaches above the menu is invisible window over the bar the menu hangs from, and the pointer lands on it instead of the next menu button. The offset must be at least the radius; Editora pins it with MenuPopupBoundsFxTest.

The three rules below hold for every menu the app draws itself: the menu bar, right-click menus, the drop-down of a menu button or a split button, and the toolbar’s overflow. The menus a platform draws (the macOS system menu bar, a tray icon’s menu) show text only; there the chord is appended to the title (MENU-02) and the tray shows neither.

  1. 1Menu button. Padding 3 × 10 on a bar with 4 px side insets; the bar and the toolbar share one -color-bg-subtle band with no rule under it.
  2. 2Icon column, 22 px. Every row has a glyph that depicts its command; where the icon set has none that fits, the app adds one rather than leave the cell blank.
  3. 3Title, 14 px Inter, the command's title with the menu's own name dropped ("Save", not "File: Save") unless two rows would then read the same.
  4. 4Chord column. Inter 11 px, periwinkle, right-aligned into one column per menu (not app-wide), read from the active keymap. Drawn by the app, not a JavaFX accelerator: Emacs chords are multi-key, which a KeyCombination cannot express, and on macOS an accelerator would bypass the key dispatcher.
  5. 5Unbound command. An empty chord cell, never a wrong chord. A live keymap switch rewrites every cell.
  6. 6Submenu row. Icon, title and an invisible chord as wide as the menu's widest, so its arrow sits at the right edge instead of halfway across.
  7. 7Card. Radius 8; the shadow falls below the menu (offset ≥ radius), so nothing invisible covers the bar.
Editora's View menu open with toggle commands and their chords
Editora's View menu in an earlier build: chords in one periwinkle column, but half the rows have no icon and every title repeats the menu's name.

The mockup is an editor tab’s menu, shortened; Editora’s has twenty-five rows.

  1. 1Anchored at the pointer. The menu's top-left corner is the click. From the keyboard (Menu key or Shift+F10) it opens under the selected row, a quarter of the way in and never off a narrow one, or just below the caret in an editor; never in the middle of the control.
  2. 2Every row has an icon, the command's own, and its chord when it has one, in the same periwinkle column as the menu bar's. The one row without an icon is a CheckMenuItem, whose tick lives in the graphic column.
  3. 3Grayed, not hidden. An action that does not apply right now (Save on an unchanged file, Reveal on an unsaved one) stays in place, dimmed. Only a row that cannot apply to this thing at all is hidden (the Git submenu on an untitled buffer).
  4. 4Separators group the rows; one that hiding has left alone hides too.
  5. 5Submenu for a family of actions (Git: stage, unstage, revert, compare, history), with its own icon.
  6. 6Labels follow state. Encrypt… becomes Lock File on an encrypted buffer, Pin Tab becomes Unpin Tab. Decided on every showing, not when the menu was built.
PropertyValueReference
Kindjavafx.scene.control.ContextMenu, auto-hide on, hide on Escape on: a popup window, unlike the paletteTabContextMenu, ConsoleContextMenu
Opens atThe pointer; from the keyboard, the selected row’s bottom edge at min(width ÷ 4, 48) px in, or under the caretRowContextMenu.anchorX, ContextMenuTarget
FontInter 14 px, pinned on .context-menu, whatever the owner’s fontapp.css
Rows34 px (padding 8 × 12); icon column 22 px; glyph scaled 0.8 from a 24 dp Material path, or a 16-unit line glyphIcons.ICON_SCALE, Icons.line
CardRadius 8, shadow radius 16 at offset Y 16.context-menu
DismissalAny press outside the menu, in any window; the next right-click; EscapeContextMenuDismissal, ContextMenuDismissalFxTest
MarkerA showing menu opened by a right-click or the Menu key carries the window property editora.rightClickMenuContextMenuDismissal.RIGHT_CLICK_MENU
Termina window with tabs in the title bar and a tab context menu
Termina's tab menu: an icon on every row, following Editora's convention.
Editora's View menu open with toggle commands and their chords
Editora's in-window menu bar with the chord column, in an earlier build whose rows still lack icons and repeat the menu's name.

Pauta 5.0.0 · · Changelog · This page in the latest edition