menu pathName ?options?
-activebackground -background -disabledforeground -relief -activeborderwidth -borderwidth -font -takefocus -activeforeground -cursor -foreground
See the options manual entry for detailed descriptions of the above options.
Command-Line Name: | -postcommand |
Database Name: | postCommand |
Database Class: | Command |
Command-Line Name: | -selectcolor |
Database Name: | selectColor |
Database Class: | Background |
Command-Line Name: | -tearoff |
Database Name: | tearOff |
Database Class: | TearOff |
Command-Line Name: | -tearoffcommand |
Database Name: | tearOffCommand |
Database Class: | TearOffCommand |
Command-Line Name: | -title |
Database Name: | title |
Database Class: | Title |
Command-Line Name: | -type |
Database Name: | type |
Database Class: | Type |
A menu is a widget that displays a collection of one-line entries arranged in a column. There exist several different types of entries, each with different properties. Entries of different types may be combined in a single menu. Menu entries are not the same as entry widgets. In fact, menu entries are not even distinct widgets; the entire menu is one widget.
Menu entries are displayed with up to three separate fields. The main field is a label in the form of a text string, a bitmap, or an image, controlled by the -label, -bitmap, and -image options for the entry. If the -accelerator option is specified for an entry then a second textual field is displayed to the right of the label. The accelerator typically describes a keystroke sequence that may be typed in the application to cause the same result as invoking the menu entry. The third field is an indicator. The indicator is present only for checkbutton or radiobutton entries. It indicates whether the entry is selected or not, and is displayed to the left of the entry's string.
In normal use, an entry becomes active (displays itself differently) whenever the mouse pointer is over the entry. If a mouse button is released over the entry then the entry is invoked. The effect of invocation is different for each type of entry; these effects are described below in the sections on individual entries.
Entries may be disabled, which causes their labels
and accelerators to be displayed
with dimmer colors.
The default menu bindings will not allow
a disabled entry to be activated or invoked.
Disabled entries may be re-enabled, at which point it becomes
possible to activate and invoke them again.
Whenever a menu's active entry is changed, a <<MenuSelect>> virtual
event is send to the menu. The active item can then be queried from
the menu, and an action can be taken, such as setting
context-sensitive help text for the entry.
A cascade entry posts its associated menu by invoking a Tcl command of the form
where menu is the path name of the associated menu, and x and y are the root-window coordinates of the upper-right corner of the cascade entry. The lower-level menu is unposted by executing a Tcl command with the formmenu post x y
where menu is the name of the associated menu.menu unpost
If a -command option is specified for a cascade entry then it is evaluated as a Tcl command whenever the entry is invoked.
MENUBARS
Any menu can be set as a menubar for a toplevel window (see
toplevel command for syntax). On the Macintosh, whenever the
toplevel is in front, this menu's cascade items will appear in the
menubar across the top of the main monitor. On Windows and Unix, this
menu's items will be displayed in a menubar accross the top of the
window. These menus will behave according to the interface guidelines
of their platforms. For every menu set as a menubar, a clone menu is
made. See the CLONES section for more information.
When Tk sees an Apple menu on the Macintosh, that menu's contents make
up the first items of the Apple menu on the screen whenever the window
containing the menubar is in front. The menu is the
first one that the user sees and has a title which is an Apple logo.
After all of the Tk-defined items, the menu will have a separator,
followed by all of the items in the user's Apple Menu Items folder.
Since the System uses a different menu definition procedure for
the Apple menu than Tk uses for its menus, and the system APIs do
not fully support everything Tk tries to do, the menu item will only
have its text displayed. No font attributes, images, bitmaps, or colors
will be displayed. In addition, a menu with a tearoff item will have
the tearoff item displayed as "(TearOff)".
When Tk see a Help menu on the Macintosh, the menu's contents are
appended to the standard help menu on the right of the user's menubar
whenever the user's menubar is in front. The first items in the menu
are provided by Apple. Similar to the Apple Menu, cusomization in this
menu is limited to what the system provides.
When Tk sees a System menu on Windows, its items are appended to the
system menu that the menubar is attached to. This menu has an icon
representing a spacebar, and can be invoked with the mouse or by typing
Alt+Spacebar. Due to limitations in the Windows API, any font changes,
colors, images, bitmaps, or tearoff images will not appear in the
system menu.
When Tk see a Help menu on X Windows, the menu is moved to be last in
the menubar and is right justified.SPECIAL MENUS IN MENUBARS
Certain menus in a menubar will be treated specially. On the Macintosh,
access to the special Apple and Help menus is provided. On Windows,
access to the Windows System menu in each window is provided. On X Windows,
a special right-justified help menu is provided. In all cases, these
menus must be created with the command name of the menubar menu concatenated
with the special name. So for a menubar named .menubar, on the Macintosh,
the special menus would be .menubar.apple and .menubar.help; on Windows,
the special menu would be .menubar.system; on X Windows, the help
menu would be .menubar.help.
CLONES
When a menu is set as a menubar for a toplevel window, or when a menu
is torn off, a clone of the menu is made. This clone is a menu widget
in its own right, but it is a child of the original. Changes in the
configuration of the original are reflected in the
clone. Additionally, any cascades that are pointed to are also cloned
so that menu traversal will work right. Clones are destroyed when
either the tearoff or menubar goes away, or when the original menu is
destroyed.
Option and the args determine the exact behavior of the command.pathName option ?arg arg ...?
Many of the widget commands for a menu take as one argument an indicator of which entry of the menu to operate on. These indicators are called indexes and may be specified in any of the following forms:
Copyright © 1989-1994 The Regents of the University of California.
Copyright © 1994-1997 Sun Microsystems, Inc.