To create a completely new menu, use the general menu syntax as a model and follow these steps:
An item can be either a character string or a graphic representation (bitmap).
A character string for items must be compatible with the menu font that is used. Character strings must be typed precisely using one of the following styles:
A bitmap for an item can be created using the X bitmap
client. Using the @ (at sign) in the menu syntax tells the window
manager that what follows is the pathname for a bitmap file:
@bitmapfile function [argument]
The following is an example of a newly created menu. The menu is
named Graphics Projects. The menu items are all
bitmaps symbolizing different graphics projects. The bitmaps are kept
in the directory /users/pat/bits. When the user selects
a symbol, the graphics program starts and opens the appropriate
graphics file.
Menu "Graphics Projects";
{
"Graphics Projects" f.title
@/users/pat/bits/fusel.bits f.exec "cad /spacestar/fusel.e12"
@/users/pat/bits/lwing.bits f.exec "cad /spacestar/lwing.s05"
@/users/pat/bits/rwing.bits f.exec "cad /spacestar/rwing.s04"
@/users/pat/bits/nose.bits f.exec "cad /spacestar/nose.e17"
}
Another method for specifying the pathname is to replace
/users/pat/ with the ~/ (tilde and slash)
characters. The ~/ specifies the user's home
directory. Another method is to use the bitmapDirectory
resource. If the bitmapDirectory resource is set to
/users/pat/bits, then a menu item could be specified as
follows:
fusel.bits f.exec "cad /spacestar/fusel.e12"
You can use mnemonics and keyboard accelerators in the menus that you create. Mnemonics are functional only when the menu is posted; accelerators are functional whether or not the menu is posted. A mnemonic specification has the following syntax:
mnemonic = _character
The _ (underbar) is placed under the first matching character in the label. If there is no matching character in the label, no mnemonic is registered with the window manager for that label. The accelerator specification is a key action with the same syntax as is used for binding keys to window manager functions:
key context function [argument]
When choosing accelerators, be careful not to use key actions that are already used in key bindings. (See the Keyboard Bindings section for information about keyboard bindings.)
The following line from the default Window menu illustrates mnemonic and accelerator syntax:
Restore _R Alt<Key>F5 f.normalize
Each function is activated by one or more of the following devices:
Any selection that uses an invalid context, an invalid function, or a function that does not apply to the current context is grayed out. For example, the Restore selection on a terminal window's Window menu and the Minimize selection on an icon's menu are invalid. Also, menu items are grayed out if they are assigned the f.nop (no operation performed) function.
If you want your new menu to appear whenever a certain mouse button or keyboard key is pressed, follow these steps:
For example, you may want to create a workspace menu that gives some control over the entire workspace (screen area). The definition of a workspace menu might look as follows:
Menu WorkspaceMenu
{
"Workspace Menu" f.title
"New Window" f.exec "mterm"
"Mail" f.exec "mail"
"Editor" f.exec "editor"
"Refresh" f.refresh
no-label f.separator
"Restart" f.restart
}
Once you have defined the menu, you need to bind the menu to a mouse
button in your .mwmrc file:
<Btn3Down> root f.menu WorkspaceMenu