16 Menus
This chapter describes the different types of menus provided by the Motif toolkit. It also presents a number of ways to
create menus in an application and talks about the issues involved in designing menu systems.
Menus provide the user with a set of choices in an application without complicating its normal visual appearance.
These convenient mini−toolboxes are essential for the user who, like an auto mechanic that is busy working under the
car, needs quick and convenient access to her tools without having to look or move away from her work. The Motif
Style Guide provides for three different types of menus: PulldownMenus, PopupMenus, and OptionMenus. Despite
the differences between the three types of menus, they all provide simple and convenient access to application
functionality.
16.1 Menu Types
PulldownMenus that are posted from the MenuBar are the most common menus in an application. the figure shows an
example of a PulldownMenu. The menu pops up when the user presses the first mouse button on a CascadeButton.
The button that posts the menu is typically user−settable, since left−handed users may want to reverse the default
button bindings. As described in Chapter 4, The Main Window, CascadeButtons may be displayed as titles in a
MenuBar or as menu items in a PulldownMenu. When the CascadeButton is a child of a MenuBar, the menu drops
down below the button when the user clicks on it. When the CascadeButton is an item in an existing menu, the new
menu pops up to the right of the item; it is sometimes referred to as a cascading menu or a pullright menu.
A PulldownMenu
Under certain conditions, it may be inconvenient for the user to stop what she is doing, move the mouse to the
MenuBar to pull down a menu, and then move the mouse back to where she was working. Having to move the mouse
away, even to another part of the same window, can reduce productivity. A PopupMenu is one solution to this
problem as it can provide immediate access to application functionality. PopupMenus are posted using the third mouse
button and can be displayed anywhere in an application. Rather than having to move the mouse, the user can simply
431
press the third mouse button to cause a PopupMenu to appear on the spot. This type of menu does not need to be
associated with a visible user−interface element. In fact, PopupMenus are usually popped up from a work area or
another region that is not affiliated with a user−interface component like a PushButton or CascadeButton. The only
drawback to this design is that there is no indication to the novice user that the menu exists. the figure shows a
PopupMenu.
A PopupMenu
The OptionMenu combines the strengths of a PulldownMenu and a PopupMenu. Like a PulldownMenu, it is posted
from a CascadeButton, but like a PopupMenu, it can be placed where it is needed. The CascadeButton is used to
display the default choice for the menu. When the user presses the button, the alternate choices are displayed in a
menu, as shown in the figure. Like a PulldownMenu, an OptionMenu is invoked using the first mouse button, but it is
displayed on top of its associated CascadeButton rather than below it.
16 Menus 16 Menus
432
An OptionMenu
The use of the third mouse button to activate PopupMenus is in sharp contrast to PulldownMenus and OptionMenus,
which are always invoked by the first mouse button. It may seem confusing to the user that some menus are invoked
by the first button while others are invoked by the third. However, there is some consistency in the fact that
PulldownMenus and OptionMenus are always attached to CascadeButtons, and buttons are always activated by the
first mouse button. By specifying that PopupMenus use the third mouse button, the first mouse button is free to be
used for other activities in an application work area, which is important since PopupMenus can be popped up
anywhere in an application.
When the user posts a menu, it is only displayed until the user makes a selection, and then it is removed. In Motif 1.2,
a menu can have an additional feature that allows it to be torn off, so that it remains posted in its own window. The
tear−off functionality is activated by a special tear−off button in the menu. The button displays a dashed line to
indicate that you can tear off the menu, like you would tear a coupon out of a newspaper. When the user presses the
tear−off button, the menu is placed in a separate window, and the user can make as many selections as she would like.
the figure shows a PulldownMenu that provides the tear−off capability.
A Pulldown Menu with tear−off functionality
To make menus even more convenient to use, menu items can have mnemonics and accelerators associated with
them. These devices are keyboard equivalents that allow the user to activate menu items using the keyboard rather
than the mouse. For example, in the figure, the underlined letter in each menu item is its mnemonic. While the menu is
posted, the user can type the specified character to activate that menu item. Accelerators are keystroke combinations
16 Menus 16 Menus
433

Get Volume 6A: Motif Programming Manual now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.