Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / man / mann / tk_menuSetFocus.n
CommitLineData
920dae64
AT
1'\"
2'\" Copyright (c) 1990-1994 The Regents of the University of California.
3'\" Copyright (c) 1994-1997 Sun Microsystems, Inc.
4'\"
5'\" See the file "license.terms" for information on usage and redistribution
6'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7'\"
8'\" RCS: @(#) $Id: menu.n,v 1.8.2.1 2004/10/28 10:19:29 dkf Exp $
9'\"
10'\" The definitions below are for supplemental macros used in Tcl/Tk
11'\" manual entries.
12'\"
13'\" .AP type name in/out ?indent?
14'\" Start paragraph describing an argument to a library procedure.
15'\" type is type of argument (int, etc.), in/out is either "in", "out",
16'\" or "in/out" to describe whether procedure reads or modifies arg,
17'\" and indent is equivalent to second arg of .IP (shouldn't ever be
18'\" needed; use .AS below instead)
19'\"
20'\" .AS ?type? ?name?
21'\" Give maximum sizes of arguments for setting tab stops. Type and
22'\" name are examples of largest possible arguments that will be passed
23'\" to .AP later. If args are omitted, default tab stops are used.
24'\"
25'\" .BS
26'\" Start box enclosure. From here until next .BE, everything will be
27'\" enclosed in one large box.
28'\"
29'\" .BE
30'\" End of box enclosure.
31'\"
32'\" .CS
33'\" Begin code excerpt.
34'\"
35'\" .CE
36'\" End code excerpt.
37'\"
38'\" .VS ?version? ?br?
39'\" Begin vertical sidebar, for use in marking newly-changed parts
40'\" of man pages. The first argument is ignored and used for recording
41'\" the version when the .VS was added, so that the sidebars can be
42'\" found and removed when they reach a certain age. If another argument
43'\" is present, then a line break is forced before starting the sidebar.
44'\"
45'\" .VE
46'\" End of vertical sidebar.
47'\"
48'\" .DS
49'\" Begin an indented unfilled display.
50'\"
51'\" .DE
52'\" End of indented unfilled display.
53'\"
54'\" .SO
55'\" Start of list of standard options for a Tk widget. The
56'\" options follow on successive lines, in four columns separated
57'\" by tabs.
58'\"
59'\" .SE
60'\" End of list of standard options for a Tk widget.
61'\"
62'\" .OP cmdName dbName dbClass
63'\" Start of description of a specific option. cmdName gives the
64'\" option's name as specified in the class command, dbName gives
65'\" the option's name in the option database, and dbClass gives
66'\" the option's class in the option database.
67'\"
68'\" .UL arg1 arg2
69'\" Print arg1 underlined, then print arg2 normally.
70'\"
71'\" RCS: @(#) $Id: man.macros,v 1.4 2000/08/25 06:18:32 ericm Exp $
72'\"
73'\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
74.if t .wh -1.3i ^B
75.nr ^l \n(.l
76.ad b
77'\" # Start an argument description
78.de AP
79.ie !"\\$4"" .TP \\$4
80.el \{\
81. ie !"\\$2"" .TP \\n()Cu
82. el .TP 15
83.\}
84.ta \\n()Au \\n()Bu
85.ie !"\\$3"" \{\
86\&\\$1 \\fI\\$2\\fP (\\$3)
87.\".b
88.\}
89.el \{\
90.br
91.ie !"\\$2"" \{\
92\&\\$1 \\fI\\$2\\fP
93.\}
94.el \{\
95\&\\fI\\$1\\fP
96.\}
97.\}
98..
99'\" # define tabbing values for .AP
100.de AS
101.nr )A 10n
102.if !"\\$1"" .nr )A \\w'\\$1'u+3n
103.nr )B \\n()Au+15n
104.\"
105.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
106.nr )C \\n()Bu+\\w'(in/out)'u+2n
107..
108.AS Tcl_Interp Tcl_CreateInterp in/out
109'\" # BS - start boxed text
110'\" # ^y = starting y location
111'\" # ^b = 1
112.de BS
113.br
114.mk ^y
115.nr ^b 1u
116.if n .nf
117.if n .ti 0
118.if n \l'\\n(.lu\(ul'
119.if n .fi
120..
121'\" # BE - end boxed text (draw box now)
122.de BE
123.nf
124.ti 0
125.mk ^t
126.ie n \l'\\n(^lu\(ul'
127.el \{\
128.\" Draw four-sided box normally, but don't draw top of
129.\" box if the box started on an earlier page.
130.ie !\\n(^b-1 \{\
131\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
132.\}
133.el \}\
134\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
135.\}
136.\}
137.fi
138.br
139.nr ^b 0
140..
141'\" # VS - start vertical sidebar
142'\" # ^Y = starting y location
143'\" # ^v = 1 (for troff; for nroff this doesn't matter)
144.de VS
145.if !"\\$2"" .br
146.mk ^Y
147.ie n 'mc \s12\(br\s0
148.el .nr ^v 1u
149..
150'\" # VE - end of vertical sidebar
151.de VE
152.ie n 'mc
153.el \{\
154.ev 2
155.nf
156.ti 0
157.mk ^t
158\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
159.sp -1
160.fi
161.ev
162.\}
163.nr ^v 0
164..
165'\" # Special macro to handle page bottom: finish off current
166'\" # box/sidebar if in box/sidebar mode, then invoked standard
167'\" # page bottom macro.
168.de ^B
169.ev 2
170'ti 0
171'nf
172.mk ^t
173.if \\n(^b \{\
174.\" Draw three-sided box if this is the box's first page,
175.\" draw two sides but no top otherwise.
176.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
177.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
178.\}
179.if \\n(^v \{\
180.nr ^x \\n(^tu+1v-\\n(^Yu
181\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
182.\}
183.bp
184'fi
185.ev
186.if \\n(^b \{\
187.mk ^y
188.nr ^b 2
189.\}
190.if \\n(^v \{\
191.mk ^Y
192.\}
193..
194'\" # DS - begin display
195.de DS
196.RS
197.nf
198.sp
199..
200'\" # DE - end display
201.de DE
202.fi
203.RE
204.sp
205..
206'\" # SO - start of list of standard options
207.de SO
208.SH "STANDARD OPTIONS"
209.LP
210.nf
211.ta 5.5c 11c
212.ft B
213..
214'\" # SE - end of list of standard options
215.de SE
216.fi
217.ft R
218.LP
219See the \\fBoptions\\fR manual entry for details on the standard options.
220..
221'\" # OP - start of full description for a single option
222.de OP
223.LP
224.nf
225.ta 4c
226Command-Line Name: \\fB\\$1\\fR
227Database Name: \\fB\\$2\\fR
228Database Class: \\fB\\$3\\fR
229.fi
230.IP
231..
232'\" # CS - begin code excerpt
233.de CS
234.RS
235.nf
236.ta .25i .5i .75i 1i
237..
238'\" # CE - end code excerpt
239.de CE
240.fi
241.RE
242..
243.de UL
244\\$1\l'|0\(ul'\\$2
245..
246.TH menu n 4.1 Tk "Tk Built-In Commands"
247.BS
248'\" Note: do not modify the .SH NAME line immediately below!
249.SH NAME
250menu, tk_menuSetFocus \- Create and manipulate menu widgets
251.SH SYNOPSIS
252.nf
253\fBmenu\fR \fIpathName \fR?\fIoptions\fR?
254\fBtk_menuSetFocus\fR \fIpathName\fR
255.SO
256\-activebackground \-borderwidth \-foreground
257\-activeborderwidth \-cursor \-relief
258\-activeforeground \-disabledforeground \-takefocus
259\-background \-font
260
261.SE
262.SH "WIDGET-SPECIFIC OPTIONS"
263.VS
264.OP \-postcommand postCommand Command
265If this option is specified then it provides a Tcl command to execute
266each time the menu is posted. The command is invoked by the \fBpost\fR
267widget command before posting the menu. Note that in Tk 8.0 on Macintosh
268and Windows, all post-commands in a system of menus are executed before any
269of those menus are posted.
270This is due to the limitations in the individual platforms' menu managers.
271.VE
272.OP \-selectcolor selectColor Background
273For menu entries that are check buttons or radio buttons, this option
274specifies the color to display in the indicator when the check button
275or radio button is selected.
276.OP \-tearoff tearOff TearOff
277This option must have a proper boolean value, which specifies
278whether or not the menu should include a tear-off entry at the
279top. If so, it will exist as entry 0 of the menu and the other
280entries will number starting at 1. The default
281menu bindings arrange for the menu to be torn off when the tear-off
282entry is invoked.
283.OP \-tearoffcommand tearOffCommand TearOffCommand
284If this option has a non-empty value, then it specifies a Tcl command
285to invoke whenever the menu is torn off. The actual command will
286consist of the value of this option, followed by a space, followed
287by the name of the menu window, followed by a space, followed by
288the name of the name of the torn off menu window. For example, if
289the option's is ``\fBa b\fR'' and menu \fB.x.y\fR is torn off to
290create a new menu \fB.x.tearoff1\fR, then the command
291``\fBa b .x.y .x.tearoff1\fR'' will be invoked.
292.VS
293.OP \-title title Title
294The string will be used to title the window created when this menu is
295torn off. If the title is NULL, then the window will have the title
296of the menubutton or the text of the cascade item from which this menu
297was invoked.
298.OP \-type type Type
299This option can be one of \fBmenubar\fR, \fBtearoff\fR, or
300\fBnormal\fR, and is set when the menu is created. While the string
301returned by the configuration database will change if this option is
302changed, this does not affect the menu widget's behavior. This is used
303by the cloning mechanism and is not normally set outside of the Tk
304library.
305.VE
306.BE
307
308.SH INTRODUCTION
309.PP
310The \fBmenu\fR command creates a new top-level window (given
311by the \fIpathName\fR argument) and makes it into a menu widget.
312Additional
313options, described above, may be specified on the command line
314or in the option database
315to configure aspects of the menu such as its colors and font.
316The \fBmenu\fR command returns its
317\fIpathName\fR argument. At the time this command is invoked,
318there must not exist a window named \fIpathName\fR, but
319\fIpathName\fR's parent must exist.
320.PP
321.VS
322A menu is a widget that displays a collection of one-line entries arranged
323in one or more columns. There exist several different types of entries,
324each with different properties. Entries of different types may be
325combined in a single menu. Menu entries are not the same as
326entry widgets. In fact, menu entries are not even distinct widgets;
327the entire menu is one widget.
328.VE
329.PP
330Menu entries are displayed with up to three separate fields.
331The main field is a label in the form of a text string,
332a bitmap, or an image, controlled by the \fB\-label\fR,
333\fB\-bitmap\fR, and \fB\-image\fR options for the entry.
334If the \fB\-accelerator\fR option is specified for an entry then a second
335textual field is displayed to the right of the label. The accelerator
336typically describes a keystroke sequence that may be typed in the
337application to cause the same result as invoking the menu entry.
338The third field is an \fIindicator\fR. The indicator is present only for
339checkbutton or radiobutton entries. It indicates whether the entry
340is selected or not, and is displayed to the left of the entry's
341string.
342.PP
343In normal use, an entry becomes active (displays itself differently)
344whenever the mouse pointer is over the entry. If a mouse
345button is released over the entry then the entry is \fIinvoked\fR.
346The effect of invocation is different for each type of entry;
347these effects are described below in the sections on individual
348entries.
349.PP
350Entries may be \fIdisabled\fR, which causes their labels
351and accelerators to be displayed
352with dimmer colors.
353The default menu bindings will not allow
354a disabled entry to be activated or invoked.
355Disabled entries may be re-enabled, at which point it becomes
356possible to activate and invoke them again.
357.VS
358.PP
359Whenever a menu's active entry is changed, a <<MenuSelect>> virtual
360event is send to the menu. The active item can then be queried from
361the menu, and an action can be taken, such as setting
362context-sensitive help text for the entry.
363.VE
364
365.SH "COMMAND ENTRIES"
366.PP
367The most common kind of menu entry is a command entry, which
368behaves much like a button widget. When a command entry is
369invoked, a Tcl command is executed. The Tcl
370command is specified with the \fB\-command\fR option.
371
372.SH "SEPARATOR ENTRIES"
373.PP
374A separator is an entry that is displayed as a horizontal dividing
375line. A separator may not be activated or invoked, and it has
376no behavior other than its display appearance.
377
378.SH "CHECKBUTTON ENTRIES"
379.PP
380A checkbutton menu entry behaves much like a checkbutton widget.
381When it is invoked it toggles back and forth between the selected
382and deselected states. When the entry is selected, a particular
383value is stored in a particular global variable (as determined by
384the \fB\-onvalue\fR and \fB\-variable\fR options for the entry); when
385the entry is deselected another value (determined by the
386\fB\-offvalue\fR option) is stored in the global variable.
387An indicator box is displayed to the left of the label in a checkbutton
388entry. If the entry is selected then the indicator's center is displayed
389in the color given by the \fB\-selectcolor\fR option for the entry;
390otherwise the indicator's center is displayed in the background color for
391the menu. If a \fB\-command\fR option is specified for a checkbutton
392entry, then its value is evaluated as a Tcl command each time the entry
393is invoked; this happens after toggling the entry's
394selected state.
395
396.SH "RADIOBUTTON ENTRIES"
397.PP
398A radiobutton menu entry behaves much like a radiobutton widget.
399Radiobutton entries are organized in groups of which only one
400entry may be selected at a time. Whenever a particular entry
401becomes selected it stores a particular value into a particular
402global variable (as determined by the \fB\-value\fR and
403\fB\-variable\fR options for the entry). This action
404causes any previously-selected entry in the same group
405to deselect itself.
406Once an entry has become selected, any change to the entry's
407associated variable will cause the entry to deselect itself.
408Grouping of radiobutton entries is determined by their
409associated variables: if two entries have the same associated
410variable then they are in the same group.
411An indicator diamond is displayed to the left of the label in each
412radiobutton entry. If the entry is selected then the indicator's
413center is displayed in the color given by the \fB\-selectcolor\fR option
414for the entry;
415otherwise the indicator's center is displayed in the background color for
416the menu. If a \fB\-command\fR option is specified for a radiobutton
417entry, then its value is evaluated as a Tcl command each time the entry
418is invoked; this happens after selecting the entry.
419
420.SH "CASCADE ENTRIES"
421.PP
422A cascade entry is one with an associated menu (determined
423by the \fB\-menu\fR option). Cascade entries allow the construction
424of cascading menus.
425The \fBpostcascade\fR widget command can be used to post and unpost
426the associated menu just next to of the cascade entry.
427The associated menu must be a child of the menu containing
428the cascade entry (this is needed in order for menu traversal to
429work correctly).
430.PP
431A cascade entry posts its associated menu by invoking a
432Tcl command of the form
433.CS
434\fImenu\fB post \fIx y\fR
435.CE
436where \fImenu\fR is the path name of the associated menu, and \fIx\fR
437and \fIy\fR are the root-window coordinates of the upper-right
438corner of the cascade entry.
439.VS
440On Unix, the lower-level menu is unposted by executing a Tcl command with
441the form
442.CS
443\fImenu\fB unpost\fR
444.CE
445where \fImenu\fR is the name of the associated menu.
446On other platforms, the platform's native code takes care of unposting the
447menu.
448.VE
449.PP
450.VS
451If a \fB\-command\fR option is specified for a cascade entry then it is
452evaluated as a Tcl command whenever the entry is invoked. This is not
453supported on Windows.
454.VE
455
456.SH "TEAR-OFF ENTRIES"
457.PP
458A tear-off entry appears at the top of the menu if enabled with the
459\fBtearOff\fR option. It is not like other menu entries in that
460it cannot be created with the \fBadd\fR widget command and
461cannot be deleted with the \fBdelete\fR widget command.
462When a tear-off entry is created it appears as a dashed line at
463the top of the menu. Under the default bindings, invoking the
464tear-off entry causes a torn-off copy to be made of the menu and
465all of its submenus.
466
467.VS
468.SH "MENUBARS"
469.PP
470Any menu can be set as a menubar for a toplevel window (see
471\fBtoplevel\fR command for syntax). On the Macintosh, whenever the
472toplevel is in front, this menu's cascade items will appear in the
473menubar across the top of the main monitor. On Windows and Unix, this
474menu's items will be displayed in a menubar across the top of the
475window. These menus will behave according to the interface guidelines
476of their platforms. For every menu set as a menubar, a clone menu is
477made. See the \fBCLONES\fR section for more information.
478.PP
479As noted, menubars may behave differently on different platforms. One
480example of this concerns the handling of checkbuttons and radiobuttons
481within the menu. While it is permitted to put these menu elements on
482menubars, they may not be drawn with indicators on some platforms, due
483to system restrictions.
484.VE
485
486.VS
487.SH "SPECIAL MENUS IN MENUBARS"
488.PP
489Certain menus in a menubar will be treated specially. On the Macintosh,
490access to the special Apple and Help menus is provided. On Windows,
491access to the Windows System menu in each window is provided. On X Windows,
492a special right-justified help menu is provided. In all cases, these
493menus must be created with the command name of the menubar menu concatenated
494with the special name. So for a menubar named .menubar, on the Macintosh,
495the special menus would be .menubar.apple and .menubar.help; on Windows,
496the special menu would be .menubar.system; on X Windows, the help
497menu would be .menubar.help.
498.PP
499When Tk sees an Apple menu on the Macintosh, that menu's contents make
500up the first items of the Apple menu on the screen whenever the window
501containing the menubar is in front. The menu is the
502first one that the user sees and has a title which is an Apple logo.
503After all of the Tk-defined items, the menu will have a separator,
504followed by all of the items in the user's Apple Menu Items folder.
505Since the System uses a different menu definition procedure for
506the Apple menu than Tk uses for its menus, and the system APIs do
507not fully support everything Tk tries to do, the menu item will only
508have its text displayed. No font attributes, images, bitmaps, or colors
509will be displayed. In addition, a menu with a tearoff item will have
510the tearoff item displayed as "(TearOff)".
511.PP
512When Tk see a Help menu on the Macintosh, the menu's contents are
513appended to the standard help menu on the right of the user's menubar
514whenever the user's menubar is in front. The first items in the menu
515are provided by Apple. Similar to the Apple Menu, customization in this
516menu is limited to what the system provides.
517.PP
518When Tk sees a System menu on Windows, its items are appended to the
519system menu that the menubar is attached to. This menu has an icon
520representing a spacebar, and can be invoked with the mouse or by typing
521Alt+Spacebar. Due to limitations in the Windows API, any font changes,
522colors, images, bitmaps, or tearoff images will not appear in the
523system menu.
524.PP
525When Tk see a Help menu on X Windows, the menu is moved to be last in
526the menubar and is right justified.
527.VE
528
529.VS
530.SH "CLONES"
531.PP
532When a menu is set as a menubar for a toplevel window, or when a menu
533is torn off, a clone of the menu is made. This clone is a menu widget
534in its own right, but it is a child of the original. Changes in the
535configuration of the original are reflected in the
536clone. Additionally, any cascades that are pointed to are also cloned
537so that menu traversal will work right. Clones are destroyed when
538either the tearoff or menubar goes away, or when the original menu is
539destroyed.
540.VE
541
542.SH "WIDGET COMMAND"
543.PP
544The \fBmenu\fR command creates a new Tcl command whose
545name is \fIpathName\fR. This
546command may be used to invoke various
547operations on the widget. It has the following general form:
548.CS
549\fIpathName option \fR?\fIarg arg ...\fR?
550.CE
551\fIOption\fR and the \fIarg\fRs
552determine the exact behavior of the command.
553.PP
554Many of the widget commands for a menu take as one argument an
555indicator of which entry of the menu to operate on. These
556indicators are called \fIindex\fRes and may be specified in
557any of the following forms:
558.TP 12
559\fInumber\fR
560Specifies the entry numerically, where 0 corresponds
561to the top-most entry of the menu, 1 to the entry below it, and
562so on.
563.TP 12
564\fBactive\fR
565Indicates the entry that is currently active. If no entry is
566active then this form is equivalent to \fBnone\fR. This form may
567not be abbreviated.
568.TP 12
569\fBend\fR
570Indicates the bottommost entry in the menu. If there are no
571entries in the menu then this form is equivalent to \fBnone\fR.
572This form may not be abbreviated.
573.TP 12
574\fBlast\fR
575Same as \fBend\fR.
576.TP 12
577\fBnone\fR
578Indicates ``no entry at all''; this is used most commonly with
579the \fBactivate\fR option to deactivate all the entries in the
580menu. In most cases the specification of \fBnone\fR causes
581nothing to happen in the widget command.
582This form may not be abbreviated.
583.TP 12
584\fB@\fInumber\fR
585In this form, \fInumber\fR is treated as a y-coordinate in the
586menu's window; the entry closest to that y-coordinate is used.
587For example, ``\fB@0\fR'' indicates the top-most entry in the
588window.
589.TP 12
590\fIpattern\fR
591If the index doesn't satisfy one of the above forms then this
592form is used. \fIPattern\fR is pattern-matched against the label of
593each entry in the menu, in order from the top down, until a
594matching entry is found. The rules of \fBTcl_StringMatch\fR
595are used.
596.PP
597The following widget commands are possible for menu widgets:
598.TP
599\fIpathName \fBactivate \fIindex\fR
600Change the state of the entry indicated by \fIindex\fR to \fBactive\fR
601and redisplay it using its active colors.
602Any previously-active entry is deactivated. If \fIindex\fR
603is specified as \fBnone\fR, or if the specified entry is
604disabled, then the menu ends up with no active entry.
605Returns an empty string.
606.TP
607\fIpathName \fBadd \fItype \fR?\fIoption value option value ...\fR?
608Add a new entry to the bottom of the menu. The new entry's type
609is given by \fItype\fR and must be one of \fBcascade\fR,
610\fBcheckbutton\fR, \fBcommand\fR, \fBradiobutton\fR, or \fBseparator\fR,
611or a unique abbreviation of one of the above. If additional arguments
612are present, they specify any of the following options:
613.RS
614.TP
615\fB\-activebackground \fIvalue\fR
616Specifies a background color to use for displaying this entry when it
617is active.
618If this option is specified as an empty string (the default), then the
619\fBactiveBackground\fR option for the overall menu is used.
620If the \fBtk_strictMotif\fR variable has been set to request strict
621Motif compliance, then this option is ignored and the \fB\-background\fR
622option is used in its place.
623This option is not available for separator or tear-off entries.
624.TP
625\fB\-activeforeground \fIvalue\fR
626Specifies a foreground color to use for displaying this entry when it
627is active.
628If this option is specified as an empty string (the default), then the
629\fBactiveForeground\fR option for the overall menu is used.
630This option is not available for separator or tear-off entries.
631.TP
632\fB\-accelerator \fIvalue\fR
633Specifies a string to display at the right side of the menu entry.
634Normally describes an accelerator keystroke sequence that may be
635typed to invoke the same function as the menu entry. This option
636is not available for separator or tear-off entries.
637.TP
638\fB\-background \fIvalue\fR
639Specifies a background color to use for displaying this entry when it
640is in the normal state (neither active nor disabled).
641If this option is specified as an empty string (the default), then the
642\fBbackground\fR option for the overall menu is used.
643This option is not available for separator or tear-off entries.
644.TP
645\fB\-bitmap \fIvalue\fR
646Specifies a bitmap to display in the menu instead of a textual
647label, in any of the forms accepted by \fBTk_GetBitmap\fR.
648This option overrides the \fB\-label\fR option
649(as controlled by the \fB\-compound\fR option)
650but may be reset
651to an empty string to enable a textual label to be displayed.
652If a \fB\-image\fR option has been specified, it overrides
653\fB\-bitmap\fR.
654This option is not available for separator or tear-off entries.
655.TP
656\fB\-columnbreak \fIvalue\fR
657.VS 8.0
658When this option is zero, the entry appears below the previous entry. When
659this option is one, the entry appears at the top of a new column in the
660menu.
661.VE 8.0
662.TP
663\fB\-command \fIvalue\fR
664Specifies a Tcl command to execute when the menu entry is invoked.
665Not available for separator or tear-off entries.
666.VS 8.4
667.TP
668\fB\-compound \fIvalue\fR
669Specifies whether the menu entry should display both an image and text,
670and if so, where the image should be placed relative to the text.
671Valid values for this option are \fBbottom\fR, \fBcenter\fR,
672\fBleft\fR, \fBnone\fR, \fBright\fR and \fBtop\fR. The default value
673is \fBnone\fR, meaning that the button will display either an image or
674text, depending on the values of the \fB\-image\fR and \fB\-bitmap\fR
675options.
676.VE
677.TP
678\fB\-font \fIvalue\fR
679Specifies the font to use when drawing the label or accelerator
680string in this entry.
681If this option is specified as an empty string (the default) then
682the \fBfont\fR option for the overall menu is used.
683This option is not available for separator or tear-off entries.
684.TP
685\fB\-foreground \fIvalue\fR
686Specifies a foreground color to use for displaying this entry when it
687is in the normal state (neither active nor disabled).
688If this option is specified as an empty string (the default), then the
689\fBforeground\fR option for the overall menu is used.
690This option is not available for separator or tear-off entries.
691.VS
692.TP
693\fB\-hidemargin \fIvalue\fR
694Specifies whether the standard margins should be drawn for this menu
695entry. This is useful when creating palette with images in them, i.e.,
696color palettes, pattern palettes, etc. 1 indicates that the margin for
697the entry is hidden; 0 means that the margin is used.
698.VE
699.TP
700\fB\-image \fIvalue\fR
701Specifies an image to display in the menu instead of a text string
702or bitmap.
703The image must have been created by some previous invocation of
704\fBimage create\fR.
705This option overrides the \fB\-label\fR and \fB\-bitmap\fR options
706(as controlled by the \fB\-compound\fR option)
707but may be reset to an empty string to enable a textual or
708bitmap label to be displayed.
709This option is not available for separator or tear-off entries.
710.TP
711\fB\-indicatoron \fIvalue\fR
712Available only for checkbutton and radiobutton entries.
713\fIValue\fR is a boolean that determines whether or not the
714indicator should be displayed.
715.TP
716\fB\-label \fIvalue\fR
717Specifies a string to display as an identifying label in the menu
718entry. Not available for separator or tear-off entries.
719.TP
720\fB\-menu \fIvalue\fR
721Available only for cascade entries. Specifies the path name of
722the submenu associated with this entry.
723The submenu must be a child of the menu.
724.TP
725\fB\-offvalue \fIvalue\fR
726Available only for checkbutton entries. Specifies the value to
727store in the entry's associated variable when the entry is
728deselected.
729.TP
730\fB\-onvalue \fIvalue\fR
731Available only for checkbutton entries. Specifies the value to
732store in the entry's associated variable when the entry is selected.
733.TP
734\fB\-selectcolor \fIvalue\fR
735Available only for checkbutton and radiobutton entries.
736Specifies the color to display in the indicator when the entry is
737selected.
738If the value is an empty string (the default) then the \fBselectColor\fR
739option for the menu determines the indicator color.
740.TP
741\fB\-selectimage \fIvalue\fR
742Available only for checkbutton and radiobutton entries.
743Specifies an image to display in the entry (in place of
744the \fB\-image\fR option) when it is selected.
745\fIValue\fR is the name of an image, which must have been created
746by some previous invocation of \fBimage create\fR.
747This option is ignored unless the \fB\-image\fR option has
748been specified.
749.TP
750\fB\-state \fIvalue\fR
751Specifies one of three states for the entry: \fBnormal\fR, \fBactive\fR,
752or \fBdisabled\fR. In normal state the entry is displayed using the
753\fBforeground\fR option for the menu and the \fBbackground\fR
754option from the entry or the menu.
755The active state is typically used when the pointer is over the entry.
756In active state the entry is displayed using the \fBactiveForeground\fR
757option for the menu along with the \fBactivebackground\fR option from
758the entry. Disabled state means that the entry
759should be insensitive: the default bindings will refuse to activate
760or invoke the entry.
761In this state the entry is displayed according to the
762\fBdisabledForeground\fR option for the menu and the
763\fBbackground\fR option from the entry.
764This option is not available for separator entries.
765.TP
766\fB\-underline \fIvalue\fR
767Specifies the integer index of a character to underline in the entry.
768This option is also queried by the default bindings and used to
769implement keyboard traversal.
7700 corresponds to the first character of the text displayed in the entry,
7711 to the next character, and so on.
772If a bitmap or image is displayed in the entry then this option is ignored.
773This option is not available for separator or tear-off entries.
774.TP
775\fB\-value \fIvalue\fR
776Available only for radiobutton entries. Specifies the value to
777store in the entry's associated variable when the entry is selected.
778If an empty string is specified, then the \fB\-label\fR option
779for the entry as the value to store in the variable.
780.TP
781\fB\-variable \fIvalue\fR
782Available only for checkbutton and radiobutton entries. Specifies
783the name of a global value to set when the entry is selected.
784For checkbutton entries the variable is also set when the entry
785is deselected. For radiobutton entries, changing the variable
786causes the currently-selected entry to deselect itself.
787.LP
788The \fBadd\fR widget command returns an empty string.
789.RE
790.TP
791\fIpathName \fBcget\fR \fIoption\fR
792Returns the current value of the configuration option given
793by \fIoption\fR.
794\fIOption\fR may have any of the values accepted by the \fBmenu\fR
795command.
796.VS
797.TP
798\fIpathName\fR \fBclone\fR \fInewPathname ?cloneType?\fR
799Makes a clone of the current menu named \fInewPathName\fR. This clone
800is a menu in its own right, but any changes to the clone are
801propogated to the original menu and vice versa. \fIcloneType\fR can be
802\fBnormal\fR, \fBmenubar\fR, or \fBtearoff\fR. Should not normally be
803called outside of the Tk library. See the \fBCLONES\fR section for
804more information.
805.VE
806.TP
807\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
808Query or modify the configuration options of the widget.
809If no \fIoption\fR is specified, returns a list describing all of
810the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for
811information on the format of this list). If \fIoption\fR is specified
812with no \fIvalue\fR, then the command returns a list describing the
813one named option (this list will be identical to the corresponding
814sublist of the value returned if no \fIoption\fR is specified). If
815one or more \fIoption\-value\fR pairs are specified, then the command
816modifies the given widget option(s) to have the given value(s); in
817this case the command returns an empty string.
818\fIOption\fR may have any of the values accepted by the \fBmenu\fR
819command.
820.TP
821\fIpathName \fBdelete \fIindex1\fR ?\fIindex2\fR?
822Delete all of the menu entries between \fIindex1\fR and
823\fIindex2\fR inclusive.
824If \fIindex2\fR is omitted then it defaults to \fIindex1\fR.
825Attempts to delete a tear-off menu entry are ignored (instead, you
826should change the \fBtearOff\fR option to remove the tear-off entry).
827.TP
828\fIpathName \fBentrycget\fR \fIindex option\fR
829Returns the current value of a configuration option for
830the entry given by \fIindex\fR.
831\fIOption\fR may have any of the values accepted by the \fBadd\fR
832widget command.
833.TP
834\fIpathName \fBentryconfigure \fIindex \fR?\fIoptions\fR?
835This command is similar to the \fBconfigure\fR command, except that
836it applies to the options for an individual entry, whereas \fBconfigure\fR
837applies to the options for the menu as a whole.
838\fIOptions\fR may have any of the values accepted by the \fBadd\fR
839widget command. If \fIoptions\fR are specified, options are modified
840as indicated
841in the command and the command returns an empty string.
842If no \fIoptions\fR are specified, returns a list describing
843the current options for entry \fIindex\fR (see \fBTk_ConfigureInfo\fR for
844information on the format of this list).
845.TP
846\fIpathName \fBindex \fIindex\fR
847Returns the numerical index corresponding to \fIindex\fR, or
848\fBnone\fR if \fIindex\fR was specified as \fBnone\fR.
849.TP
850\fIpathName \fBinsert \fIindex\fR \fItype \fR?\fIoption value option value ...\fR?
851Same as the \fBadd\fR widget command except that it inserts the new
852entry just before the entry given by \fIindex\fR, instead of appending
853to the end of the menu. The \fItype\fR, \fIoption\fR, and \fIvalue\fR
854arguments have the same interpretation as for the \fBadd\fR widget
855command. It is not possible to insert new menu entries before the
856tear-off entry, if the menu has one.
857.TP
858\fIpathName \fBinvoke \fIindex\fR
859Invoke the action of the menu entry. See the sections on the
860individual entries above for details on what happens. If the
861menu entry is disabled then nothing happens. If the
862entry has a command associated with it then the result of that
863command is returned as the result of the \fBinvoke\fR widget
864command. Otherwise the result is an empty string. Note: invoking
865a menu entry does not automatically unpost the menu; the default
866bindings normally take care of this before invoking the \fBinvoke\fR
867widget command.
868.TP
869\fIpathName \fBpost \fIx y\fR
870Arrange for the menu to be displayed on the screen at the root-window
871coordinates given by \fIx\fR and \fIy\fR. These coordinates are
872adjusted if necessary to guarantee that the entire menu is visible on
873the screen. This command normally returns an empty string.
874If the \fBpostCommand\fR option has been specified, then its value is
875executed as a Tcl script before posting the menu and the result of
876that script is returned as the result of the \fBpost\fR widget
877command.
878If an error returns while executing the command, then the error is
879returned without posting the menu.
880.TP
881\fIpathName \fBpostcascade \fIindex\fR
882Posts the submenu associated with the cascade entry given by
883\fIindex\fR, and unposts any previously posted submenu.
884If \fIindex\fR doesn't correspond to a cascade entry,
885or if \fIpathName\fR isn't posted,
886the command has no effect except to unpost any currently posted
887submenu.
888.TP
889\fIpathName \fBtype \fIindex\fR
890Returns the type of the menu entry given by \fIindex\fR.
891This is the \fItype\fR argument passed to the \fBadd\fR widget
892command when the entry was created, such as \fBcommand\fR
893or \fBseparator\fR, or \fBtearoff\fR for a tear-off entry.
894.TP
895\fIpathName \fBunpost\fR
896.VS
897Unmap the window so that it is no longer displayed. If a
898lower-level cascaded menu is posted, unpost that menu. Returns an
899empty string. This subcommand does not work on Windows and the
900Macintosh, as those platforms have their own way of unposting menus.
901.VE
902.TP
903\fIpathName \fByposition \fIindex\fR
904Returns a decimal string giving the y-coordinate within the menu
905window of the topmost pixel in the entry specified by \fIindex\fR.
906
907.SH "MENU CONFIGURATIONS"
908.PP
909The default bindings support four different ways of using menus:
910.VS
911.TP
912\fBPulldown Menus in Menubar\fR
913This is the most command case. You create a menu widget that will become the
914menu bar. You then add cascade entries to this menu, specifying the
915pull down menus you wish to use in your menu bar. You then create all
916of the pulldowns. Once you have done this, specify the menu using the
917\fB\-menu\fR option of the toplevel's widget command. See the
918\fBtoplevel\fR manual entry for details.
919.VE
920.TP
921\fBPulldown Menus in Menu Buttons\fR
922This is the compatable way to do menu bars. You create one menubutton
923widget for each top-level menu, and typically you arrange a series of
924menubuttons in a row in a menubar window. You also create the top-level menus
925and any cascaded submenus, and tie them together with \fB\-menu\fR
926options in menubuttons and cascade menu entries. The top-level menu must
927be a child of the menubutton, and each submenu must be a child of the
928menu that refers to it. Once you have done this, the default bindings
929will allow users to traverse and invoke the tree of menus via its
930menubutton; see the \fBmenubutton\fR manual entry for details.
931.TP
932\fBPopup Menus\fR
933Popup menus typically post in response to a mouse button press or
934keystroke. You create the popup menus and any cascaded submenus,
935then you call the \fBtk_popup\fR procedure at the appropriate time
936to post the top-level menu.
937.TP
938\fBOption Menus\fR
939An option menu consists of a menubutton with an associated menu
940that allows you to select one of several values. The current value
941is displayed in the menubutton and is also stored in a global
942variable. Use the \fBtk_optionMenu\fR procedure to create option
943menubuttons and their menus.
944.TP
945\fBTorn-off Menus\fR
946You create a torn-off menu by invoking the tear-off entry at
947the top of an existing menu. The default bindings will create a new menu
948that is a copy of the original menu and leave it permanently
949posted as a top-level window. The torn-off menu behaves just
950the same as the original menu.
951
952.SH "DEFAULT BINDINGS"
953.PP
954Tk automatically creates class bindings for menus that give them
955the following default behavior:
956.IP [1]
957When the mouse enters a menu, the entry underneath the mouse
958cursor activates; as the mouse moves around the menu, the active
959entry changes to track the mouse.
960.IP [2]
961When the mouse leaves a menu all of the entries in the menu
962deactivate, except in the special case where the mouse moves from
963a menu to a cascaded submenu.
964.IP [3]
965When a button is released over a menu, the active entry (if any) is invoked.
966The menu also unposts unless it is a torn-off menu.
967.IP [4]
968The Space and Return keys invoke the active entry and
969unpost the menu.
970.IP [5]
971If any of the entries in a menu have letters underlined with
972the \fB\-underline\fR option, then pressing one of the underlined
973letters (or its upper-case or lower-case equivalent) invokes that
974entry and unposts the menu.
975.IP [6]
976The Escape key aborts a menu selection in progress without invoking any
977entry. It also unposts the menu unless it is a torn-off menu.
978.IP [7]
979The Up and Down keys activate the next higher or lower entry
980in the menu. When one end of the menu is reached, the active
981entry wraps around to the other end.
982.IP [8]
983The Left key moves to the next menu to the left.
984If the current menu is a cascaded submenu, then the submenu is
985unposted and the current menu entry becomes the cascade entry
986in the parent.
987If the current menu is a top-level menu posted from a
988menubutton, then the current menubutton is unposted and the
989next menubutton to the left is posted.
990Otherwise the key has no effect.
991The left-right order of menubuttons is determined by their stacking
992order: Tk assumes that the lowest menubutton (which by default
993is the first one created) is on the left.
994.IP [9]
995The Right key moves to the next menu to the right.
996If the current entry is a cascade entry, then the submenu is
997posted and the current menu entry becomes the first entry
998in the submenu.
999Otherwise, if the current menu was posted from a
1000menubutton, then the current menubutton is unposted and the
1001next menubutton to the right is posted.
1002.PP
1003Disabled menu entries are non-responsive: they don't activate and
1004they ignore mouse button presses and releases.
1005.PP
1006.VS 8.4
1007Several of the bindings make use of the command \fBtk_menuSetFocus\fR.
1008It saves the current focus and sets the focus to its \fIpathName\fR
1009argument, which is a menu widget.
1010.VE
1011.PP
1012The behavior of menus can be changed by defining new bindings for
1013individual widgets or by redefining the class bindings.
1014
1015.SH BUGS
1016.PP
1017At present it isn't possible to use the
1018option database to specify values for the options to individual
1019entries.
1020
1021.SH KEYWORDS
1022menu, widget