[ Previous | Next | Contents | Glossary | Home | Search ]
Motif 2.1 Programmer's Guide



Chapter 6. Menus and Options

A menu is a widget that allows the user to make a choice among actions or states. When the menu is visible, the user makes a choice by activating a button in the menu, usually by pressing Btn1, osfSelect, or osfActivate on the button. Some buttons also have mnemonics that allow the user to activate them by pressing the mnemonic keys when the menu is visible. Buttons can also have accelerators, which activate the buttons whether or not the menu is visible.

Like any other widget, a menu must be controlled by some parent widget. However, some types of Motif menu may be shared by more than one widget. (Only one widget will be the parent, but the same menu can be accessed from any other widget on the menu's "post-from" list.)

Motif has four basic kinds of menu:

  1. MenuBar. This menu is normally always managed within some component of an application, often the MainWindow. It usually consists of a row of CascadeButtons. When the user activates a button in the menu, a PulldownMenu menu appears with one set of top-level choices that apply to the application component.

  2. PopupMenu. This menu contains a set of choices that apply to a component of the application. The menu is not visible until the user takes an action that posts it, usually pressing Btn3 in the associated component or pressing osfMenu when the component has keyboard focus. A PopupMenu can contain buttons that take action or change state directly. It can also contain CascadeButtons that cause PulldownMenus to appear.

  3. PulldownMenu. This menu is associated with a CascadeButton in a MenuBar, a PopupMenu, or another PulldownMenu. The menu is not visible until the user posts it by activating the associated CascadeButton. Like a PopupMenu, a PulldownMenu can contain buttons that take action or change state directly. It can also contain CascadeButtons that cause other PulldownMenus to appear.

  4. OptionMenu. This menu allows the user to choose among one set of choices, usually mutually exclusive attributes or states. It consists of a label, a selection area, and a PulldownMenu. The selection area is a CascadeButtonGadget whose label shows the currently selected option. The PulldownMenu contains the set of options. The user posts the PulldownMenu by activating the CascadeButtonGadget or by pressing MAlt along with a mnemonic. When the user activates a button in the PulldownMenu, that button becomes the newly selected option.

    RowColumn is the widget that Motif uses as a menu. A RowColumn can also be a nonmenu WorkArea. One use for a WorkArea is to contain a set of ToggleButtons constituting a RadioBox or a CheckBox. When the user selects a ToggleButton, its state changes from on to off or from off to on. In a RadioBox, only one ToggleButton at a time can be on; in a CheckBox, more than one ToggleButton can be on.

    RowColumn performs special geometry management to align and lay out its children in a variety of ways. An application can use a RowColumn WorkArea to take advantage of the RowColumn geometry management for a set of widgets. For details see Chapter 14.

    In addition to menus, users can also select choices by interacting with a ComboBox or a SpinBox.

    A ComboBox is a combination of a List child and a TextField child. This combination gives users two ways to select a choice. That is, the user can either click on a displayed item in the List or type the choice directly into the TextField.

    A SpinBox displays a combination of arrows and one or more textual widgets (usually Labels and TextFields). The user makes selections by clicking on the arrows. The arrow clicking increments or decrements the values displayed in the textual widgets. For example, a SpinBox would be an excellent widget to use when the user needs to select a date. The user could click on SpinBox arrows to adjust month and day fields.


  5. [ Previous | Next | Contents | Glossary | Home | Search ]