Contextual Menus
A contextual menu is a menu displayed when a user presses mouse button 2 while the pointer is over an object or area associated with that menu. Contextual menus are one of two main types of menusthe other type being drop-down menus, which users choose from a menu bar. Figure 33 shows a contextual menu.
Figure 33 Contextual Menu (Displayed Over a Table)
Contextual menus provide quick access to menu items available elsewhere in an application. A contextual menu should include only frequently used menu items; otherwise, it will be hard to use.
Although contextual menus and drop-down menus are alike in most ways, contextual menus differ from drop-down menus in the following ways:
Contextual menus are displayed only when a user presses mouse button 2 or Shift-F10.
Contextual menus are composed of:
Menu items that affect the object or selection under the pointer
Menu items for the entire window
Menu items that do not require a selection
The correct menu items for a contextual menu depend on where the pointer is when a user opens that menu. Table 7 describes the correct types of menu items for contextual menus opened from various pointer positions.
Table 7 Correct Menu Items for Contextual Menus
Pointer Position When Menu Opens |
Correct Menu Items |
Not on an object or selection |
|
On a single object that is not selected |
|
On a selection |
|
If a user opens a contextual menu for an object that is not selected, that object becomes selected. The new selection cancels any previous selection.
Some objects have a default command, executed if a user double-clicks the object. When displaying the contextual menu for such an object, use bold to display the menu item that activates the default command. For an example, see Figure 33, in which Open is the default command.
The following guidelines help you design contextual menus. These guidelines supplement those in Chapter 9 of Java Look and Feel Design Guidelines, 2d ed.
TIP
Each item in a contextual menu must be available elsewhere in your application. Provide contextual menus only as conveniences that are redundant with other controlstypically with items in your application's drop-down menus.
If your application has contextual menus, ensure that it has them for all its objects.
Include only frequently used menu items in contextual menus.
If the object of a contextual menu has a default command, place that command at the top of the contextual menu. In addition, display the command in bold.
Do not display unavailable menu items that cannot apply to the current object. In an open contextual menu, dim unavailable menu items that can apply to the current object.
In a contextual menu for a selection, ensure that each menu item that operates on an object can be applied to each object in the selection. (That is, ensure that the set of menu items for the selected objects is an intersection, not a union.)
When designing contextual menus, follow the rules in Table 7 on page 48.