The Menu class allows the creation and control of context menus and application-level menus.
Create a new menu. A menu is populated with MenuActions
... actions |
One or more MenuActions or Menus to be displayed in the menu. Menu arguments will create sub-menus. |
Show the menu if it is not already shown. Note that unlike most Views, Menus are not destroyed when they are closed - front can be used to re-generate a single menu again and again.
point |
A Point at which to show the menu. Default to the current mouse cursor position. |
action |
The action that should appear at the specified point coordinates. Should be an action contained in the menu. |
b |
If true, menu is / will be torn off from its parent and become a free-floating menu. |
Create an identical copy of the menu. The new menu will not be shown until .front
is called.
Menus broadcast several kinds of events that can be registered for with the standard Object: -addDependant calls. Events broadcast by menu:
\aboutToShow
\aboutToHide
\triggered
(with the MenuAction that was triggered)\hovered
(with action that was hovered over)Events example
One or more MenuActions can be attached to any View object. The shortcut key combinations for these actions will become available, and the actions will appear in the context menu for that view.
See View: -setContextMenuActions, View: -addMenuAction, View: -removeMenuAction for more information.
A more complex menu.