8.10 Menus

8.10.1 Description

A menu is a widget that displays a collection of one-line entries arranged in one or more columns. There exist several different types of entries, each with different properties. Entries of different types may be combined in a single menu. Menu entries are not the same as entry widgets. In fact, menu entries are not even distinct widgets; the entire menu is one widget.

Menu description records are records of the form menu(E1 E2 .. Ex param1:value1 ... paramY:valueY) where Ex are records of the form command(...), checkbutton(...), radiobutton(...), cascade(...) or separator. The first three record types (command, checkbutton and radiobutton) are very similar to the widgets of the same name, and have many parameters in common. The cascade(...) record form is similar to the menu(...) one as that entry pulls out a sub-menu. The separator record inserts an horizontal line.

Menu descriptions usage:

CLONES

When a menu is set as a menubar for a toplevel window, or when a menu is torn off, a clone of the menu is made. This clone is a menu widget in its own right, but it is a child of the original. Changes in the configuration of the original are reflected in the clone. Additionally, any cascades that are pointed to are also cloned so that menu traversal will work right. Clones are destroyed when either the tearoff or menubar goes away, or when the original menu is destroyed.

8.10.2 Parameters

The menu description support the following parameters:

8.10.3 Interface

8.10.4 Menu entries

Menu entries are displayed with up to three separate fields. The main field is a label in the form of a text string, a bitmap, or an image, controlled by the label, bitmap, and image options for the entry. If the accelerator option is specified for an entry then a second textual field is displayed to the right of the label. The accelerator typically describes a keystroke sequence that may be typed in the application to cause the same result as invoking the menu entry. The third field is an indicator. The indicator is present only for checkbutton or radiobutton entries. It indicates whether the entry is selected or not, and is displayed to the left of the entry's string.

In normal use, an entry becomes active (displays itself differently) whenever the mouse pointer is over the entry. If a mouse button is released over the entry then the entry is invoked. The effect of invocation is different for each type of entry; these effects are described below in the sections on individual entries.

Entries may be disabled, which causes their labels and accelerators to be displayed with dimmer colors. The default menu bindings will not allow a disabled entry to be activated or invoked. Disabled entries may be re-enabled, at which point it becomes possible to activate and invoke them again.

Whenever a menu's active entry is changed, a MenuSelect virtual event is send to the menu. The active item can then be queried from the menu, and an action can be taken, such as setting context-sensitive help text for the entry.

Tear-off

A tear-off entry appears at the top of the menu if enabled with the tearoff option of the menu. It is not an entry like others because it is not created the same way. When a tear-off entry is created it appears as a dashed line at the top of the menu. Under the default bindings, invoking the tear-off entry causes a torn-off copy to be made of the menu and all of its submenus.

Command

Description

The most common kind of menu entry is a command entry, which behaves much like a button widget. When a command entry is invoked, the Oz command specified by the action parameter is executed.

A command menu entry is described by a record of the form:

command(parameter1:value1 ... parameterX:valueX)

Parameters

Interface

The object controlling the menu entry implements the following methods:

Checkbutton

Description

A checkbutton menu entry behaves much like a checkbutton widget. When it is invoked it toggles back and forth between the selected and deselected states. An indicator box is displayed to the left of the label in a checkbutton entry. If the entry is selected then the indicator's center is displayed in the color given by the selectcolor option for the entry; otherwise the indicator's center is displayed in the background color for the menu. If an action option is specified for a checkbutton entry, then the Oz command is executed each time the user change the state of the entry; this happens after toggling the entry's selected state.

A checkbutton menu entry is described by a record of the form:

checkbutton(parameter1:value1 ... parameterX:valueX)

Parameters

Interface

The object controlling the menu entry implements the following methods:

Radiobutton

Description

A radiobutton menu entry behaves much like a radiobutton widget. Radiobutton entries are organized in groups along with the radiobutton and tbradiobutton widgets. Widgets are grouped together if their group parameters are set to the same atom. Only one entry of a group may be selected at a time. An indicator diamond is displayed to the left of the label in each radiobutton entry. If the entry is selected then the indicator's center is displayed in the color given by the selectcolor option for the entry; otherwise the indicator's center is displayed in the background color for the menu. If an action option is specified for a radiobutton entry, then the specified Oz command is executed just after the user selects the entry.

A radiobutton menu entry is described by a record of the form:

radiobutton(parameter1:value1 ... parameterX:valueX)

Parameters

Interface

The object controlling the menu entry implements the following methods:

Cascade

Description

A cascade entry is one with an associated menu (determined by the menu option). Cascade entries allow the construction of cascading menus.

A cascade menu entry is described by a record of the form:

cascade(parameter1:value1 ... parameterX:valueX)

Parameters

Interface

The object controlling the menu entry implements the following methods:

Separator

Description

A separator is an entry that is displayed as a horizontal dividing line. A separator may not be activated or invoked, and it has no behavior other than its display appearance.

A separator menu entry is described by a record of the form:

separator(parameter1:value1 ... parameterX:valueX)

Parameters

Interface

The object controlling the menu entry implements the following methods:


Donatien Grolaux
Version 1.3.0 (20040413)