Menu:
Filter:
Classes | GUI

Menu : AbstractActionView : View : QObject : Object

Context and application-level menus
Source: Menu.sc

Description

The Menu class allows the creation and control of context menus and application-level menus.

Class Methods

Menu.new( ... actions)

Create a new menu. A menu is populated with MenuActions

Arguments:

... actions

One or more MenuActions or Menus to be displayed in the menu. Menu arguments will create sub-menus.

Discussion:

Inherited class methods

Undocumented class methods

Menu.newFrom(otherMenu)

Menu.qtClass

Instance Methods

Control

.front(point, action)

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.

Arguments:

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.

.title

.title = title

The title of the menu.

Arguments:

title

A String.

.tearOff

.tearOff = b

Arguments:

b

If true, menu is / will be torn off from its parent and become a free-floating menu.

.copy

Create an identical copy of the menu. The new menu will not be shown until .front is called.

Events

Menus broadcast several kinds of events that can be registered for with the standard Object: -addDependant calls. Events broadcast by menu:

Events example

Context Menus

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.

Inherited instance methods

Undocumented instance methods

.asMenu

.asMenuAction

.onHide

.onHovered(action)

.onShow

.onTriggered(action)

.remove

.string

.string = title

Examples

A more complex menu.