deft.menu

Menu system: menu bars, popup menus, menu items and keyboard accelerators.

A MenuItem is a lightweight value describing one command (id, label, optional accelerator such as "Ctrl+N", and an onClicked event). Menu wraps a native popup HMENU; MenuBar wraps a window menu HMENU and is attached to a Window via Window.setMenuBar.

Menu and accelerator commands both arrive as WM_COMMAND with a null lParam; Window routes them here through dispatchMenuCommand, which fires the matching item's onClicked. Accelerators are collected from every item carrying an accelerator string into a single HACCEL table that the message loop feeds to TranslateAccelerator.

The native menus provide MSAA accessibility for free: screen readers announce menu names, item labels, accelerator text, and checked/disabled state.

Members

Classes

Menu
class Menu

A popup menu — a list of items, separators and submenus.

MenuBar
class MenuBar

A window menu bar — the horizontal strip of top-level menus.

Enums

MenuItemKind
enum MenuItemKind

The kind of a menu item.

Functions

dispatchMenuCommand
bool dispatchMenuCommand(int id)

Dispatch a menu or accelerator command to its item's onClicked.

nextMenuId
int nextMenuId()

Generate a unique menu command id (used when an item is appended with id 0).

parseAccelerator
Accelerator parseAccelerator(string spec)

Parse an accelerator string such as "Ctrl+Shift+N" or "F5".

showPopupMenu
void showPopupMenu(Menu menu, Widget parent, int x, int y)

Show menu as a context menu owned by parent.

Structs

Accelerator
struct Accelerator

Result of parsing an accelerator string.

MenuItem
struct MenuItem

One menu command.

Meta