Document revision date: 10 November 2000

## DECwindows Companion to the OSF/Motif Style Guide

Previous | Contents | Index

## 2.5 Designing Pop-up Menus

Pop-up menus provide users with shortcuts for accessing pull-down menu items.

Because pop-up menus appear at the current pointer position when MB3 is pressed, users do not need to move the mouse very far. Pop-up menus allow users to keep their attention focused on their work while choosing an action. Invoking functions exclusively from pull-down menus and dialog boxes can require extensive mouse movements, resulting in lower productivity.

### 2.5.1 Characteristics to Give to Pop-up Menus

Design the pop-up menus to have the following characteristics:

- Make each item in a pop-up menu available through another mechanism, such as a pull-down menu or a dialog box.
  Note that a pop-up menu serves only as a shortcut to menu items; it must not be the exclusive mechanism for reaching those items.
- Give pop-up menus a title. (This characteristic is optional.)
  For example, the pop-up menu for the default Motif workspace menu has the title Workspace. Figure 2-6 shows a pop-up menu without a title.

Figure 2-6 Pop-up Menu

Organize pop-up menus in one of the following manners:

- If the contents of a pop-up menu are similar to those of pull-down menus, preserve the general order that you would use in a pull-down menu. The pop-up menu order will then be consistent with the pull-down menus. For example, if the pop-up menu has some items from the File and Edit menus, place the items from the File menu first and the items from the Edit menu second, with a separator between the two groups.
- If your application's pop-up menus are very different from the pull-down menus, follow these guidelines:
  - Place menu items in descending order from the more frequently invoked to the less frequently invoked.
    To determine which items are most frequently used, involve users and analyze your application by recording the keystrokes users make and the commands they use. Consider using separators in pop-up menus.
  - Order menu items alphabetically.
  - Order menu items logically.
    The pop-up menu in Figure 2-6 is ordered logically.

Include the most frequently used functions of your applications in pop-up menus. Pop-up menus may contain a heterogeneous group of functions. Because pop-up menus act as accelerators, they require less rigid categories of items than do pull-down menus.

There are two ways to implement pop-up menus:

- Create one generic pop-up menu to display all the items you feel are appropriate.
  Then, depending on the context when users invoke the menu, disable the inappropriate items.
- Create different menus for different contexts.
  For example, create one pop-up menu for contexts in which users of a graphics editor have selected a graphical object, and a different pop-up menu when they have selected text. Even if you create separate pop-up menus, there still might be situations in which you disable certain menu items.

### 2.5.2 Determining the Actions of Pop-up Menus

Have items in a pop-up menu act on the current selection (if there is one), according to the following guidelines:

- Do not change the current selection when users display a pop-up menu.
- Keep the selected object selected after users use the menu so that they can perform further actions if they want.
  Of course, if users delete selected items, these items will not be present to be selected or deselected.
- Do not allow users to select multiple objects from the pop-up menu if the actions on these selections are inconsistent.
  For example, if you allow users to choose two objects to open, make sure your application opens them in two different windows. If users want to delete two objects, make sure that your application deletes both.

Make your application do one of the following two things if users have not selected any items:

- While the menu is displayed, highlight the item or objects that will be affected by the menu functions.
- Display a generic pop-up menu with menu items that pertain to the "no-item-selected" context. For example, in a graphics editor, a pop-up menu could have menu items for creating objects.

### 2.5.3 Choosing Between a Pop-up Menu or a Control Panel

Pop-up menus provide users with quick and direct access to application functions. Control panels and modeless dialog boxes that contain push buttons perform a similar role. Use pop-up menus when users are focusing on the work area, and when moving the mouse between the control panel and work area would be distracting. Use a control panel or a modeless dialog box when users want the controls to be constantly visible. You can also use tear-off menus to give the user the choice of keeping the controls visible. (See Section 2.6 for information about tear-off menus.)

### 2.5.4 Designing Pop-up Menus with Submenus

When combining pop-up menus with submenus, follow these guidelines:

- Place menu items within the submenus in logical groups.
- Do not use an extensive hierarchy of submenus because the amount of mouse movement involved defeats the purpose of the pop-up menu.
- Keep only three or fewer levels in a pop-up menu hierarchy, as a general rule.

Figure 2-7 illustrates a pop-up menu with a submenu.

Figure 2-7 Pop-up Menu with a Submenu

## 2.6 Designing Tear-off Menus

A tear-off menu is one that can be torn off into a secondary window. After the menu is torn off, the user can position it and use it in the same way as a dialog box.

When menus are torn off, they appear in a separate window that can be directly accessed. Tear-off menus should be used when elements in a menu can be activated many times in succession. Pull-down, option, cascade, and pop-up menus can all become tear-off menus.

For example, the View pull-down menu, which can contain different views as well as Expand and Collapse items, is a good candidate for a tear-off menu. Most Options pull-down menus, which are used infrequently, might not be appropriate for tearing off. However, Options menus for setting the font family and size for desktop publishing applications are good candidates for becoming tear-off menus.

You should avoid creating tear-off menus from pop-up menus that are context sensitive, with items changing depending on the location of the pointer.

Programming Hint To set the tear-off attribute of a menu, set the XmNtearoffModel resource for the pull-down menu:
    XmPulldownMenu
        {
            arguments
                {
                    XmNtearoffModel = XmTEAR_OFF_ENABLED;
                };
        };

## 2.7 Items in the File Menu

The File menu provides commands that allow users to manage files. Place the File menu to the far left in the menu bar (in left to right environments), and give it a mnemonic of F. The mnemonic allows a user to press a single letter on the keyboard in order to select a menu item. Indicate the mnemonic with an underscore.

Motif recommends the following menu items for the File menu:

- New
- Open...
- Save
- Save As...
- Print
- Close
- Exit

You can improve the usefulness of the File menu by adding the following items:

- Include...
- Import...
- Revert...
- Export...
- Print...

Figure 2-8 shows a File menu with Digital's additional menu items in the recommended order.

Figure 2-8 A File Menu and Its Menu Items

Group the menu items according to the following:

- Initiating actions
- Saving actions
- Printing actions
- Exiting actions

The functions of the File menu items are as follows:

> #### New

> The New menu item must open a new file in the current window. It must clear existing data from the client area and update the current file name. If users specify a new file name, you can display the file name in the title area or in a status area with a full pathname. If they do not specify a file name, display the term "Untitled" in the title area. Digital suggests that if you give New an accelerator, make the accelerator Ctrl+N.

> To accommodate users who already have a file open when they choose the New menu item, have your application display a question message box that asks if users want to save the file. Figure 2-9 shows a question message box that does this.

> #### Open...

> The Open menu item must open an existing file. When users click on this item, it must bring up a dialog box that prompts users for the name of the file. Digital suggests that if you give Open an accelerator, make the accelerator Ctrl+O.

> To accommodate users who already have a file open when they choose another file to be opened, you can do either of the following:

> - Have your application display a question box that asks if users want to save the file before closing it and opening another. Figure 2-9 shows a "save file" question message box.

>   Figure 2-9 A" Save File" Question Message Box

- Have your application display an Open File dialog box with a check button that asks if users want to open the file in a new window. Figure 2-10 shows an example of such a dialog box.

  Figure 2-10 An" Open in New Window" Check Box in an Open File Dialog Box

  #### Include...

  Make the Include menu item add the contents of a specific file to the currently opened file. When users choose Include, generate a File Selection dialog box and add the included material at the current insertion point.

  #### Import...

  The Import menu item is similar to Open, except that it converts the format of the specified file to the native format of the application. Users need to supply both the name of the file to import and the current format of that file.

  #### Save

  The Save menu item must save the currently opened file without removing it from the client area. If users have not already named the currently opened file, Save must generate a Save As... dialog box that prompts users for a file name. Digital suggests that if you give Save an accelerator, make the accelerator Ctrl+S.

  #### Save As...

  The Save As menu item must save the current file under a new name without removing it from the client area. It must also update the name of the file in the title bar or status area. Save As must generate a dialog box that prompts users for a file name. Figure 2-11 shows a Save As dialog box that not only allows users to save a file by typing a name in the Selection field, but also allows users to save a file in different formats.

  If your application runs on an operating system that does not save multiple versions of a file (for example, UNIX or Windows NT operating systems), you can have a message box displayed to warn users whenever saving a file with the name they specified will cause the application to overwrite an existing file. If your application will run on a variety of platforms, you could make the display of this warning message customizable.

  When users choose Save As, they usually want to keep the newly named file in the same directory as the current file. If you use a file selection box in a Save As operation, initially set the directory to match the directory of the open file. If the user has performed a Save As operation before, leave the directory in its previous state.

  Figure 2-11 A Save As Dialog Box That Allows Users to Save in Different File Formats

  #### Revert

  Make the Revert menu item display the last saved version of the current file. This menu item deletes all the work done since the user last saved the file. If the operating system (for example, the OpenVMS operating system) supports multiple versions, consider allowing users to perform multiple Revert actions. Disable the Revert item if there is nothing to revert in the application.

  Figure 2-12 shows a dialog box displayed by activating the Revert menu item.

  Figure 2-12 A Revert Dialog Box

  #### Export

  The Export menu item is similar to Save As, but causes the application to convert the file format from the native application format to a different one. Users need to specify both the name of the file to be exported and the new format that they want the application to convert the file to.

  #### Print

  The Print menu item must print the current file using the current settings of a Print dialog box without displaying the box.

  #### Print...

  Make the Print menu item generate a Print dialog box. For information on a Print dialog box, see Section 6.1. Digital suggests that if you give Print an accelerator, make the accelerator Ctrl+P.

  #### Close

  The Close menu item must close only the current primary window and its associated secondary windows; that is, the window family. You are encouraged to supply this menu item for applications with more than one primary window so that users can remove a window without going to the window menu on the border or without running the Motif window manager. Make Close perform the same action as the Close menu item from the window menu. Digital suggests that if you give Close an accelerator, make the accelerator Ctrl+C.

  Closing the last primary window is the same as exiting the application. Use the following guidelines to help you decide what constitutes the last primary window:

  - If your application has primary windows that are of equal importance, you should design the application so that closing the last window will exit the application. For example, if your application is a text editor where each primary window is a duplicate, arrange to have the application exit when the user closes the last window.
  - If your application has primary windows whose functions differ, consider designing the application so that there is a main window from which the other windows are generated. Thus, closing the main window exits the application, while closing one of the other primary windows causes that window to be removed from the workspace.

  If users can lose data by closing the last window, provide a message box that prompts users to save changes.

  #### Exit

  The Exit menu item must end the current session and remove all windows associated with that application. Exit is equivalent to closing the last primary window of your application. To accommodate users who want to exit, but have not saved current changes to a file, generate a message box that prompts users to save changes.

  ## 2.8 Items in the Selected Menu

  The Selected menu is optional. It contains items that refer to the selected objects in the window. For example, in a mail application, the selected objects could include drawers, folders, or messages. The user would select a series of mail folders and then display the Selected menu. The menu items would apply to the selected folders.

  Figure 2-13 shows a standard menu bar that contains a Selected menu with seven menu items. You can use different menu items that are appropriate for your application.

  Figure 2-13 A Selected Menu and Its Menu Items

  Note that the File menu differs from the Selected menu. The File menu contains operations for the application as a whole, as well as file-like actions; the Selected menu items apply only to those objects that the user has just selected.

  If an object can be opened in one of several views, consider using a cascade menu for the Selected menu item. For example, if you want the user to be able to open a directory in either an icon or tree view, use a cascade menu instead of a generic Open menu item.

          Open-> Icon View
                 Tree View

  ## 2.9 Items in the Edit Menu

  The Edit menu provides commands that allow users to manipulate text or graphics within a file and between files. Place the Edit menu to the right of the File menu, or Selected menu if one is defined, in left to right environments, and give it a mnemonic of E.

  Motif recommends the following items in the Edit menu:

  - Undo (Alt+Delete)
  - Cut (Remove)
  - Copy (Shift+Remove)
  - Paste (Insert Here)
  - Clear
  - Delete

  You can enhance the usefulness of this menu by adding the following items:

  - Find...
  - Select All

  Figure 2-14 shows an Edit menu with the additional menu items.

  Figure 2-14 An Edit Menu and Its Menu Items

  Group the menu items according to the following:

  - Undo and Redo actions
  - Systemwide clipboard actions
  - Other actions

  The functions of the Edit menu items are as follows:

  > #### Undo (Alt+Delete), Redo

  > The Undo menu item must reverse the effects of a previous operation. The Redo menu item reverses the effects of an Undo operation.

  > There are two forms of Undo --- single-level and multilevel --- as follows:

  > - If your application supports only single-level Undo, the Undo item appears in the menu by default. Once users perform an Undo operation, make the menu item change to Redo until users perform another action that reenables Undo.
  > - If your application supports multilevel Undo, include menu items for both Undo and Redo. Once users perform an Undo operation, they can either perform another Undo or choose Redo.

  > When an Undo operation is not possible in a given context, disable the Undo menu item. For example, when users open a file, keep the Undo menu item disabled until they make a change to the file. If your application does not support the Undo function, do not display the Undo menu item in the Edit menu.

  > You can make the Undo operation more specific by altering the menu item for Undo as the function changes. For example, change the label of the menu item to any of the following when appropriate:

  > - Undo Cut
  > - Undo Paste
  > - Undo Rotate
  > - Undo Typing
  > - Undo Fill
  > - Undo Font

  > Once a user operation is undone, have your application support redoing the operation. For example, change the label of the menu item to any of the following when appropriate:

  > - Redo Cut
  > - Redo Paste
  > - Redo Rotate
  > - Redo Typing
  > - Redo Fill
  > - Redo Font

  > #### Cut (Remove)

  > The Cut menu item must transfer selected information to the clipboard and delete the information from your application. Decide whether the area that was occupied by the removed data is left blank or whether the remaining data fills the space. Usually graphics applications leave the space blank, while text applications fill the space with the remaining text.

  > #### Copy (Shift+Remove)

  > The Copy menu item must transfer the selection to the clipboard without removing the original data from the client area. Do not allow this action to alter data in your application.

  > #### Paste (Insert Here)

  > The Paste menu item must copy data from the clipboard into the application. When there is more than one possible destination for the paste, use the following guidelines:
  > - When the focus policy is explicit, paste data to the control with the keyboard focus.
  > - When the focus policy is implicit (pointer), paste data to the control with the destination cursor. This guideline applies only for text widgets.
  > - Allow users to place the selected data by dragging an outline of the data to be pasted around the screen using MB2, and dropping it in the desired location by releasing MB2.

  > Decide whether the pasted data is reformatted to fit in the client area. Text applications usually reformat the pasted data to fit into the margins of the text field; graphics applications usually do not.

  > Do not allow Paste to affect the contents of the clipboard.

  > In addition to the Edit menu items, you should implement the Motif drag-and-drop functions.

  > #### Clear

  > The Clear menu item must delete the selection without copying it to the clipboard. The Clear menu item does not compress the remaining data to fill the space that was occupied by the cleared data. Users must be able to undo a clear operation.

  > #### Delete

  > The Delete menu item must remove the current selection without copying it to the clipboard. Make Delete compress the remaining data to fill the space that was occupied by the cleared data. Allow users to undo a delete operation.

  > #### Find...

  > The Find menu item enables users to search for an object that they specify. When they select the Find menu item, make a search dialog box appear.

  > #### Select All

  > Make the Select All menu item select all the data in the file, not just the data that is currently visible.

  Previous | Next | Contents | Index

  | privacy and legal statement |
  5637PRO_004.HTML