Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / Tk::Menu.3
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "MENU 1"
132.TH MENU 1 "2000-12-30" "perl v5.8.0" "User Contributed Perl Documentation"
133.SH "NAME"
134Tk::Menu \- Create and manipulate Menu widgets
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137\&\ \fI$menu\fR = \fI$parent\fR\->\fBMenu\fR(?\fIoptions\fR?);
138.SH "STANDARD OPTIONS"
139.IX Header "STANDARD OPTIONS"
140\&\fB\-activebackground\fR \fB\-background\fR \fB\-disabledforeground\fR \fB\-relief\fR
141\&\fB\-activeborderwidth\fR \fB\-borderwidth\fR \fB\-font\fR \fB\-takefocus\fR
142\&\fB\-activeforeground\fR \fB\-cursor\fR \fB\-foreground\fR
143.PP
144See Tk::options for details of the standard options.
145.SH "WIDGET-SPECIFIC OPTIONS"
146.IX Header "WIDGET-SPECIFIC OPTIONS"
147.IP "Name: \fBpostCommand\fR" 4
148.IX Item "Name: postCommand"
149.PD 0
150.IP "Class: \fBCommand\fR" 4
151.IX Item "Class: Command"
152.IP "Switch: \fB\-postcommand\fR" 4
153.IX Item "Switch: -postcommand"
154.PD
155If this option is specified then it provides a callback to execute
156each time the menu is posted. The callback is invoked by the \fBpost\fR
157method before posting the menu. Note that in 8.0 on Macintosh
158and Windows, all commands in a menu systems are executed before any
159are posted. This is due to the limitations in the individual platforms'
160menu managers.
161.IP "Name: \fBselectColor\fR" 4
162.IX Item "Name: selectColor"
163.PD 0
164.IP "Class: \fBBackground\fR" 4
165.IX Item "Class: Background"
166.IP "Switch: \fB\-selectcolor\fR" 4
167.IX Item "Switch: -selectcolor"
168.PD
169For menu entries that are check buttons or radio buttons, this option
170specifies the color to display in the indicator when the check button
171or radio button is selected.
172.IP "Name: \fBtearOff\fR" 4
173.IX Item "Name: tearOff"
174.PD 0
175.IP "Class: \fBTearOff\fR" 4
176.IX Item "Class: TearOff"
177.IP "Switch: \fB\-tearoff\fR" 4
178.IX Item "Switch: -tearoff"
179.PD
180This option must have a proper boolean value, which specifies
181whether or not the menu should include a tear-off entry at the
182top. If so, it will exist as entry 0 of the menu and the other
183entries will number starting at 1. The default
184menu bindings arrange for the menu to be torn off when the tear-off
185entry is invoked.
186.IP "Name: \fBtearOffCommand\fR" 4
187.IX Item "Name: tearOffCommand"
188.PD 0
189.IP "Class: \fBTearOffCommand\fR" 4
190.IX Item "Class: TearOffCommand"
191.IP "Switch: \fB\-tearoffcommand\fR" 4
192.IX Item "Switch: -tearoffcommand"
193.PD
194If this option has a non-empty value, then it specifies a perl/Tk callback
195to invoke whenever the menu is torn off. The actual command will
196consist of the value of this option, followed by a space, followed
197by the name of the menu window, followed by a space, followed by
198the name of the name of the torn off menu window. For example, if
199the option's is ``\fBa b\fR'' and menu \fB.x.y\fR is torn off to
200create a new menu \fB.x.tearoff1\fR, then the command
201``\fBa b .x.y .x.tearoff1\fR'' will be invoked.
202.IP "Name: \fBtitle\fR" 4
203.IX Item "Name: title"
204.PD 0
205.IP "Class: \fBTitle\fR" 4
206.IX Item "Class: Title"
207.IP "Switch: \fB\-title\fR" 4
208.IX Item "Switch: -title"
209.PD
210The string will be used to title the window created when this menu is
211torn off. If the title is \s-1NULL\s0, then the window will have the title
212of the menubutton or the text of the cascade item from which this menu
213was invoked.
214.IP "Name: \fBtype\fR" 4
215.IX Item "Name: type"
216.PD 0
217.IP "Class: \fBType\fR" 4
218.IX Item "Class: Type"
219.IP "Switch: \fB\-type\fR" 4
220.IX Item "Switch: -type"
221.PD
222This option can be one of \fBmenubar\fR, \fBtearoff\fR, or
223\&\fBnormal\fR, and is set when the menu is created. While the string
224returned by the configuration database will change if this option is
225changed, this does not affect the menu widget's behavior. This is used
226by the cloning mechanism and is not normally set outside of the Tk
227library.
228.SH "DESCRIPTION"
229.IX Header "DESCRIPTION"
230The \fBMenu\fR method creates a new top-level window (given
231by the \f(CW$widget\fR argument) and makes it into a menu widget.
232Additional
233options, described above, may be specified on the command line
234or in the option database
235to configure aspects of the menu such as its colors and font.
236The \fBmenu\fR command returns its
237\&\f(CW$widget\fR argument. At the time this command is invoked,
238there must not exist a window named \f(CW$widget\fR, but
239\&\f(CW$widget\fR's parent must exist.
240.PP
241A menu is a widget that displays a collection of one-line entries arranged
242in one or more columns. There exist several different types of entries,
243each with different properties. Entries of different types may be
244combined in a single menu. Menu entries are not the same as
245entry widgets. In fact, menu entries are not even distinct widgets;
246the entire menu is one widget.
247.PP
248Menu entries are displayed with up to three separate fields.
249The main field is a label in the form of a text string,
250a bitmap, or an image, controlled by the \fB\-label\fR,
251\&\fB\-bitmap\fR, and \fB\-image\fR options for the entry.
252If the \fB\-accelerator\fR option is specified for an entry then a second
253textual field is displayed to the right of the label. The accelerator
254typically describes a keystroke sequence that may be typed in the
255application to cause the same result as invoking the menu entry.
256The third field is an \fIindicator\fR. The indicator is present only for
257checkbutton or radiobutton entries. It indicates whether the entry
258is selected or not, and is displayed to the left of the entry's
259string.
260.PP
261In normal use, an entry becomes active (displays itself differently)
262whenever the mouse pointer is over the entry. If a mouse
263button is released over the entry then the entry is \fIinvoked\fR.
264The effect of invocation is different for each type of entry;
265these effects are described below in the sections on individual
266entries.
267.PP
268Entries may be \fIdisabled\fR, which causes their labels
269and accelerators to be displayed
270with dimmer colors.
271The default menu bindings will not allow
272a disabled entry to be activated or invoked.
273Disabled entries may be re\-enabled, at which point it becomes
274possible to activate and invoke them again.
275.PP
276Whenever a menu's active entry is changed, a <<MenuSelect>> virtual
277event is sent to the menu. The active item can then be queried from
278the menu, and an action can be taken, such as setting
279context-sensitive help text for the entry.
280.Sh "\s-1COMMAND\s0 \s-1ENTRIES\s0"
281.IX Subsection "COMMAND ENTRIES"
282The most common kind of menu entry is a command entry, which
283behaves much like a button widget. When a command entry is
284invoked, a callback is executed. The callback
285is specified with the \fB\-command\fR option.
286.Sh "\s-1SEPARATOR\s0 \s-1ENTRIES\s0"
287.IX Subsection "SEPARATOR ENTRIES"
288A separator is an entry that is displayed as a horizontal dividing
289line. A separator may not be activated or invoked, and it has
290no behavior other than its display appearance.
291.Sh "\s-1CHECKBUTTON\s0 \s-1ENTRIES\s0"
292.IX Subsection "CHECKBUTTON ENTRIES"
293A checkbutton menu entry behaves much like a checkbutton widget.
294When it is invoked it toggles back and forth between the selected
295and deselected states. When the entry is selected, a particular
296value is stored in a particular global variable (as determined by
297the \fB\-onvalue\fR and \fB\-variable\fR options for the entry); when
298the entry is deselected another value (determined by the
299\&\fB\-offvalue\fR option) is stored in the global variable.
300An indicator box is displayed to the left of the label in a checkbutton
301entry. If the entry is selected then the indicator's center is displayed
302in the color given by the \fB\-selectcolor\fR option for the entry;
303otherwise the indicator's center is displayed in the background color for
304the menu. If a \fB\-command\fR option is specified for a checkbutton
305entry, then its value is evaluated each time the entry
306is invoked; this happens after toggling the entry's
307selected state.
308.Sh "\s-1RADIOBUTTON\s0 \s-1ENTRIES\s0"
309.IX Subsection "RADIOBUTTON ENTRIES"
310A radiobutton menu entry behaves much like a radiobutton widget.
311Radiobutton entries are organized in groups of which only one
312entry may be selected at a time. Whenever a particular entry
313becomes selected it stores a particular value into a particular
314global variable (as determined by the \fB\-value\fR and
315\&\fB\-variable\fR options for the entry). This action
316causes any previously-selected entry in the same group
317to deselect itself.
318Once an entry has become selected, any change to the entry's
319associated variable will cause the entry to deselect itself.
320Grouping of radiobutton entries is determined by their
321associated variables: if two entries have the same associated
322variable then they are in the same group.
323An indicator diamond is displayed to the left of the label in each
324radiobutton entry. If the entry is selected then the indicator's
325center is displayed in the color given by the \fB\-selectcolor\fR option
326for the entry;
327otherwise the indicator's center is displayed in the background color for
328the menu. If a \fB\-command\fR option is specified for a radiobutton
329entry, then its value is evaluated each time the entry
330is invoked; this happens after selecting the entry.
331.Sh "\s-1CASCADE\s0 \s-1ENTRIES\s0"
332.IX Subsection "CASCADE ENTRIES"
333A cascade entry is one with an associated menu (determined
334by the \fB\-menu\fR option). Cascade entries allow the construction
335of cascading menus.
336The \fBpostcascade\fR method can be used to post and unpost
337the associated menu just next to of the cascade entry.
338The associated menu must be a child of the menu containing
339the cascade entry (this is needed in order for menu traversal to
340work correctly).
341.PP
342A cascade entry posts its associated menu by invoking
343.Sp
344.RS 4
345\&\fI$menu\fR\->\fBpost\fR(\fIx,y\fR)
346.RE
347.PP
348where \fImenu\fR is the path name of the associated menu, and \fIx\fR
349and \fIy\fR are the root-window coordinates of the upper-right
350corner of the cascade entry.
351On Unix, the lower-level menu is unposted by executing
352.Sp
353.RS 4
354\&\fI$menu\fR\->\fBunpost\fR
355.RE
356.PP
357where \fImenu\fR is the name of the associated menu.
358On other platforms, the platform's native code takes care of unposting the
359menu.
360.PP
361If a \fB\-command\fR option is specified for a cascade entry then it is
362evaluated whenever the entry is invoked. This is not supported on Windows.
363.Sh "TEAR-OFF \s-1ENTRIES\s0"
364.IX Subsection "TEAR-OFF ENTRIES"
365A tear-off entry appears at the top of the menu if enabled with the
366\&\fBtearOff\fR option. It is not like other menu entries in that
367it cannot be created with the \fBadd\fR method and
368cannot be deleted with the \fBdelete\fR method.
369When a tear-off entry is created it appears as a dashed line at
370the top of the menu. Under the default bindings, invoking the
371tear-off entry causes a torn-off copy to be made of the menu and
372all of its submenus.
373.Sh "\s-1MENUBARS\s0"
374.IX Subsection "MENUBARS"
375Any menu can be set as a menubar for a toplevel window (see the
376Toplevel constructor for syntax). On the Macintosh, whenever the
377toplevel is in front, this menu's cascade items will appear in the
378menubar across the top of the main monitor. On Windows and Unix, this
379menu's items will be displayed in a menubar accross the top of the
380window. These menus will behave according to the interface guidelines
381of their platforms. For every menu set as a menubar, a clone menu is
382made. See \*(L"\s-1CLONES\s0\*(R" for more information.
383.Sh "\s-1SPECIAL\s0 \s-1MENUS\s0 \s-1IN\s0 \s-1MENUBARS\s0"
384.IX Subsection "SPECIAL MENUS IN MENUBARS"
385Certain menus in a menubar will be treated specially. On the Macintosh,
386access to the special Apple and Help menus is provided. On Windows,
387access to the Windows System menu in each window is provided. On X Windows,
388a special right-justified help menu is provided. In all cases, these
389menus must be created with the command name of the menubar menu concatenated
390with the special name. So for a menubar named .menubar, on the Macintosh,
391the special menus would be .menubar.apple and .menubar.help; on Windows,
392the special menu would be .menubar.system; on X Windows, the help
393menu would be .menubar.help.
394.PP
395When Tk sees an Apple menu on the Macintosh, that menu's contents make
396up the first items of the Apple menu on the screen whenever the window
397containing the menubar is in front. The menu is the
398first one that the user sees and has a title which is an Apple logo.
399After all of the Tk-defined items, the menu will have a separator,
400followed by all of the items in the user's Apple Menu Items folder.
401Since the System uses a different menu definition procedure for
402the Apple menu than Tk uses for its menus, and the system APIs do
403not fully support everything Tk tries to do, the menu item will only
404have its text displayed. No font attributes, images, bitmaps, or colors
405will be displayed. In addition, a menu with a tearoff item will have
406the tearoff item displayed as \*(L"(TearOff)\*(R".
407.PP
408When Tk see a Help menu on the Macintosh, the menu's contents are
409appended to the standard help menu on the right of the user's menubar
410whenever the user's menubar is in front. The first items in the menu
411are provided by Apple. Similar to the Apple Menu, cusomization in this
412menu is limited to what the system provides.
413.PP
414When Tk sees a System menu on Windows, its items are appended to the
415system menu that the menubar is attached to. This menu has an icon
416representing a spacebar, and can be invoked with the mouse or by typing
417Alt+Spacebar. Due to limitations in the Windows \s-1API\s0, any font changes,
418colors, images, bitmaps, or tearoff images will not appear in the
419system menu.
420.PP
421When Tk see a Help menu on X Windows, the menu is moved to be last in
422the menubar and is right justified.
423.Sh "\s-1SEPARATORS\s0 \s-1IN\s0 \s-1MENUBARS\s0"
424.IX Subsection "SEPARATORS IN MENUBARS"
425Separator entries are not displayed in menubars.
426The \fIlast\fR separator entry causes remaining entries to be
427right justified.
428.Sh "\s-1CLONES\s0"
429.IX Subsection "CLONES"
430When a menu is set as a menubar for a toplevel window, or when a menu
431is torn off, a clone of the menu is made. This clone is a menu widget
432in its own right, but it is a child of the original. Changes in the
433configuration of the original are reflected in the
434clone. Additionally, any cascades that are pointed to are also cloned
435so that menu traversal will work right. Clones are destroyed when
436either the tearoff or menubar goes away, or when the original menu is
437destroyed.
438.Sh "\s-1WIDGET\s0 \s-1METHODS\s0"
439.IX Subsection "WIDGET METHODS"
440The \fBMenu\fR method creates a widget object.
441This object supports the \fBconfigure\fR and \fBcget\fR methods
442described in Tk::options which can be used to enquire and
443modify the options described above.
444The widget also inherits all the methods provided by the generic
445Tk::Widget class, and the Tk::Wm class.
446.PP
447Many of the methods for a menu take as one argument an
448indicator of which entry of the menu to operate on. These
449indicators are called \fIindex\fRes and may be specified in
450any of the following forms:
451.IP "\fInumber\fR" 4
452.IX Item "number"
453Specifies the entry numerically, where 0 corresponds
454to the top-most entry of the menu, 1 to the entry below it, and
455so on.
456.IP "\fBactive\fR" 4
457.IX Item "active"
458Indicates the entry that is currently active. If no entry is
459active then this form is equivalent to \fBnone\fR. This form may
460not be abbreviated.
461.IP "\fBend\fR" 4
462.IX Item "end"
463Indicates the bottommost entry in the menu. If there are no
464entries in the menu then this form is equivalent to \fBnone\fR.
465This form may not be abbreviated.
466.IP "\fBlast\fR" 4
467.IX Item "last"
468Same as \fBend\fR.
469.IP "\fBnone\fR" 4
470.IX Item "none"
471Indicates ``no entry at all''; this is used most commonly with
472the \fBactivate\fR option to deactivate all the entries in the
473menu. In most cases the specification of \fBnone\fR causes
474nothing to happen in the method.
475This form may not be abbreviated.
476.IP "\fB@\fR\fInumber\fR" 4
477.IX Item "@number"
478In this form, \fInumber\fR is treated as a y\-coordinate in the
479menu's window; the entry closest to that y\-coordinate is used.
480For example, ``\fB@0\fR'' indicates the top-most entry in the
481window.
482.IP "\fIpattern\fR" 4
483.IX Item "pattern"
484If the index doesn't satisfy one of the above forms then this
485form is used. \fIPattern\fR is pattern-matched against the label of
486each entry in the menu, in order from the top down, until a
487matching entry is found.
488(In perl/Tk the matching is under review, but exact match
489should work.)
490.PP
491The following methods are possible for menu widgets:
492.IP "\fI$menu\fR\->\fBactivate\fR(\fIindex\fR)" 4
493.IX Item "$menu->activate(index)"
494Change the state of the entry indicated by \fIindex\fR to \fBactive\fR
495and redisplay it using its active colors.
496Any previously-active entry is deactivated. If \fIindex\fR
497is specified as \fBnone\fR, or if the specified entry is
498disabled, then the menu ends up with no active entry.
499Returns an empty string.
500.IP "\fI$menu\fR\->\fBadd\fR(\fItype, \fR?\fIoption, value, option, value, ...\fR?)" 4
501.IX Item "$menu->add(type, ?option, value, option, value, ...?)"
502Add a new entry to the bottom of the menu. The new entry's type
503is given by \fItype\fR and must be one of \fBcascade\fR,
504\&\fBcheckbutton\fR, \fBcommand\fR, \fBradiobutton\fR, or \fBseparator\fR,
505or a unique abbreviation of one of the above. If additional arguments
506are present, they specify any of the following options:
507.RS 4
508.IP "\fB\-activebackground\fR => \fIvalue\fR" 8
509.IX Item "-activebackground => value"
510Specifies a background color to use for displaying this entry when it
511is active.
512If this option is specified as an empty string (the default), then the
513\&\fBactiveBackground\fR option for the overall menu is used.
514If the \fB$Tk::strictMotif\fR variable has been set to request strict
515Motif compliance, then this option is ignored and the \fB\-background\fR
516option is used in its place.
517This option is not available for separator or tear-off entries.
518.IP "\fB\-activeforeground\fR => \fIvalue\fR" 8
519.IX Item "-activeforeground => value"
520Specifies a foreground color to use for displaying this entry when it
521is active.
522If this option is specified as an empty string (the default), then the
523\&\fBactiveForeground\fR option for the overall menu is used.
524This option is not available for separator or tear-off entries.
525.IP "\fB\-accelerator\fR => \fIvalue\fR" 8
526.IX Item "-accelerator => value"
527Specifies a string to display at the right side of the menu entry.
528Normally describes an accelerator keystroke sequence that may be
529typed to invoke the same function as the menu entry. This option
530is not available for separator or tear-off entries.
531.IP "\fB\-background\fR => \fIvalue\fR" 8
532.IX Item "-background => value"
533Specifies a background color to use for displaying this entry when it
534is in the normal state (neither active nor disabled).
535If this option is specified as an empty string (the default), then the
536\&\fBbackground\fR option for the overall menu is used.
537This option is not available for separator or tear-off entries.
538.IP "\fB\-bitmap\fR => \fIvalue\fR" 8
539.IX Item "-bitmap => value"
540Specifies a bitmap to display in the menu instead of a textual
541label, in any of the forms accepted by \fBTk_GetBitmap\fR.
542This option overrides the \fB\-label\fR option but may be reset
543to an empty string to enable a textual label to be displayed.
544If a \fB\-image\fR option has been specified, it overrides
545\&\fB\-bitmap\fR.
546This option is not available for separator or tear-off entries.
547.IP "\fB\-columnbreak\fR => \fIvalue\fR" 8
548.IX Item "-columnbreak => value"
549When this option is zero, the appears below the previous entry. When
550this option is one, the menu appears at the top of a new column in the
551menu.
552.IP "\fB\-command\fR => \fIvalue\fR" 8
553.IX Item "-command => value"
554For command, checkbutton, and radiobutton entries, specifies a
555callback to execute when the menu entry is invoked.
556For cascade entries, specifies a callback to execute
557when the entry is activated (i.e. just before its submenu is
558posted).
559Not available for separator or tear-off entries.
560.IP "\fB\-font\fR => \fIvalue\fR" 8
561.IX Item "-font => value"
562Specifies the font to use when drawing the label or accelerator
563string in this entry.
564If this option is specified as an empty string (the default) then
565the \fBfont\fR option for the overall menu is used.
566This option is not available for separator or tear-off entries.
567.IP "\fB\-foreground\fR => \fIvalue\fR" 8
568.IX Item "-foreground => value"
569Specifies a foreground color to use for displaying this entry when it
570is in the normal state (neither active nor disabled).
571If this option is specified as an empty string (the default), then the
572\&\fBforeground\fR option for the overall menu is used.
573This option is not available for separator or tear-off entries.
574.IP "\fB\-hidemargin\fR => \fIvalue\fR" 8
575.IX Item "-hidemargin => value"
576Specifies whether the standard margins should be drawn for this menu
577entry. This is useful when creating palette with images in them, i.e.,
578color palettes, pattern palettes, etc. 1 indicates that the margin for
579the entry is hidden; 0 means that the margin is used.
580.IP "\fB\-image\fR => \fIvalue\fR" 8
581.IX Item "-image => value"
582Specifies an image to display in the menu instead of a text string
583or bitmap
584The image must have been created by some previous invocation of
585\&\fBimage create\fR.
586This option overrides the \fB\-label\fR and \fB\-bitmap\fR options
587but may be reset to an empty string to enable a textual or
588bitmap label to be displayed.
589This option is not available for separator or tear-off entries.
590.IP "\fB\-indicatoron\fR => \fIvalue\fR" 8
591.IX Item "-indicatoron => value"
592Available only for checkbutton and radiobutton entries.
593\&\fIValue\fR is a boolean that determines whether or not the
594indicator should be displayed.
595.IP "\fB\-label\fR => \fIvalue\fR" 8
596.IX Item "-label => value"
597Specifies a string to display as an identifying label in the menu
598entry. Not available for separator or tear-off entries.
599.IP "\fB\-menu\fR => \fIvalue\fR" 8
600.IX Item "-menu => value"
601Available only for cascade entries. Specifies the path name of
602the submenu associated with this entry.
603The submenu must be a child of the menu.
604.IP "\fB\-offvalue\fR => \fIvalue\fR" 8
605.IX Item "-offvalue => value"
606Available only for checkbutton entries. Specifies the value to
607store in the entry's associated variable when the entry is
608deselected.
609.IP "\fB\-onvalue\fR => \fIvalue\fR" 8
610.IX Item "-onvalue => value"
611Available only for checkbutton entries. Specifies the value to
612store in the entry's associated variable when the entry is selected.
613.IP "\fB\-selectcolor\fR => \fIvalue\fR" 8
614.IX Item "-selectcolor => value"
615Available only for checkbutton and radiobutton entries.
616Specifies the color to display in the indicator when the entry is
617selected.
618If the value is an empty string (the default) then the \fBselectColor\fR
619option for the menu determines the indicator color.
620.IP "\fB\-selectimage\fR => \fIvalue\fR" 8
621.IX Item "-selectimage => value"
622Available only for checkbutton and radiobutton entries.
623Specifies an image to display in the entry (in place of
624the \fB\-image\fR option) when it is selected.
625\&\fIValue\fR is the name of an image, which must have been created
626by some previous invocation of \fBimage create\fR.
627This option is ignored unless the \fB\-image\fR option has
628been specified.
629.IP "\fB\-state\fR => \fIvalue\fR" 8
630.IX Item "-state => value"
631Specifies one of three states for the entry: \fBnormal\fR, \fBactive\fR,
632or \fBdisabled\fR. In normal state the entry is displayed using the
633\&\fBforeground\fR option for the menu and the \fBbackground\fR
634option from the entry or the menu.
635The active state is typically used when the pointer is over the entry.
636In active state the entry is displayed using the \fBactiveForeground\fR
637option for the menu along with the \fBactivebackground\fR option from
638the entry. Disabled state means that the entry
639should be insensitive: the default bindings will refuse to activate
640or invoke the entry.
641In this state the entry is displayed according to the
642\&\fBdisabledForeground\fR option for the menu and the
643\&\fBbackground\fR option from the entry.
644This option is not available for separator entries.
645.IP "\fB\-underline\fR => \fIvalue\fR" 8
646.IX Item "-underline => value"
647Specifies the integer index of a character to underline in the entry.
648This option is also queried by the default bindings and used to
649implement keyboard traversal.
6500 corresponds to the first character of the text displayed in the entry,
6511 to the next character, and so on.
652If a bitmap or image is displayed in the entry then this option is ignored.
653This option is not available for separator or tear-off entries.
654.IP "\fB\-value\fR => \fIvalue\fR" 8
655.IX Item "-value => value"
656Available only for radiobutton entries. Specifies the value to
657store in the entry's associated variable when the entry is selected.
658If an empty string is specified, then the \fB\-label\fR option
659for the entry as the value to store in the variable.
660.IP "\fB\-variable\fR => \fIvalue\fR" 8
661.IX Item "-variable => value"
662Available only for checkbutton and radiobutton entries. Specifies
663the name of a global value to set when the entry is selected.
664For checkbutton entries the variable is also set when the entry
665is deselected. For radiobutton entries, changing the variable
666causes the currently-selected entry to deselect itself.
667.RE
668.RS 4
669.Sp
670The \fBadd\fR method returns an empty string.
671.RE
672.IP "\fI$menu\fR\->\fBclone\fR(\fI$parent\fR ?, \fIcloneType?\fR)" 4
673.IX Item "$menu->clone($parent ?, cloneType?)"
674Makes a clone of the current menu as a child of \fI$parent\fR. This clone
675is a menu in its own right, but any changes to the clone are
676propogated to the original menu and vice versa. \fIcloneType\fR can be
677\&\fBnormal\fR, \fBmenubar\fR, or \fBtearoff\fR. Should not normally be
678called outside of the Tk library. See \*(L"\s-1CLONES\s0\*(R" for
679more information.
680.IP "\fI$menu\fR\->\fBdelete\fR(\fIindex1\fR?, \fIindex2\fR?)" 4
681.IX Item "$menu->delete(index1?, index2?)"
682Delete all of the menu entries between \fIindex1\fR and
683\&\fIindex2\fR inclusive.
684If \fIindex2\fR is omitted then it defaults to \fIindex1\fR.
685Attempts to delete a tear-off menu entry are ignored (instead, you
686should change the \fBtearOff\fR option to remove the tear-off entry).
687.IP "\fI$menu\fR\->\fBentrycget\fR(\fIindex, option\fR)" 4
688.IX Item "$menu->entrycget(index, option)"
689Returns the current value of a configuration option for
690the entry given by \fIindex\fR.
691\&\fIOption\fR may have any of the values accepted by the \fBadd\fR
692method.
693.IP "\fI$menu\fR\->\fBentryconfigure\fR(\fIindex\fR ?,\fIoptions\fR?)" 4
694.IX Item "$menu->entryconfigure(index ?,options?)"
695This method is similar to the \fBconfigure\fR method, except that
696it applies to the options for an individual entry, whereas \fBconfigure\fR
697applies to the options for the menu as a whole.
698\&\fIOptions\fR may have any of the values accepted by the \fBadd\fR
699method. If \fIoptions\fR are specified, options are modified
700as indicated
701in the method call and the method returns an empty string.
702If no \fIoptions\fR are specified, returns a list describing
703the current options for entry \fIindex\fR (see Tk::options for
704information on the format of this list).
705.IP "\fI$menu\fR\->\fBindex\fR(\fIindex\fR)" 4
706.IX Item "$menu->index(index)"
707Returns the numerical index corresponding to \fIindex\fR, or
708\&\fBnone\fR if \fIindex\fR was specified as \fBnone\fR.
709.IP "\fI$menu\fR\->\fBinsert\fR(\fIindex, type\fR?, \fI\-option\fR=>\fIvalue\fR, ...?)" 4
710.IX Item "$menu->insert(index, type?, -option=>value, ...?)"
711Same as the \fBadd\fR method except that it inserts the new
712entry just before the entry given by \fIindex\fR, instead of appending
713to the end of the menu. The \fItype\fR, \fI\-option\fR, and \fIvalue\fR
714arguments have the same interpretation as for the \fBadd\fR widget
715method. It is not possible to insert new menu entries before the
716tear-off entry, if the menu has one.
717.IP "\fI$menu\fR\->\fBinvoke\fR(\fIindex\fR)" 4
718.IX Item "$menu->invoke(index)"
719Invoke the action of the menu entry. See the sections on the
720individual entries above for details on what happens. If the
721menu entry is disabled then nothing happens. If the
722entry has a callback associated with it then the result of that
723callback is returned as the result of the \fBinvoke\fR widget
724method. Otherwise the result is an empty string. Note: invoking
725a menu entry does not automatically unpost the menu; the default
726bindings normally take care of this before invoking the \fBinvoke\fR
727method.
728.IP "\fI$menu\fR\->\fBpost\fR(\fIx, y\fR)" 4
729.IX Item "$menu->post(x, y)"
730Arrange for the menu to be displayed on the screen at the root-window
731coordinates given by \fIx\fR and \fIy\fR. These coordinates are
732adjusted if necessary to guarantee that the entire menu is visible on
733the screen. This method normally returns an empty string.
734If the \fBpostCommand\fR option has been specified, then its value is
735executed before posting the menu and the result of
736that callback is returned as the result of the \fBpost\fR widget
737method.
738If an error returns while executing the method, then the error is
739returned without posting the menu.
740.IP "\fI$menu\fR\->\fBpostcascade\fR(\fIindex\fR)" 4
741.IX Item "$menu->postcascade(index)"
742Posts the submenu associated with the cascade entry given by
743\&\fIindex\fR, and unposts any previously posted submenu.
744If \fIindex\fR doesn't correspond to a cascade entry,
745or if \fI$menu\fR isn't posted,
746the method has no effect except to unpost any currently posted
747submenu.
748.IP "\fI$menu\fR\->\fBtype\fR(\fIindex\fR)" 4
749.IX Item "$menu->type(index)"
750Returns the type of the menu entry given by \fIindex\fR.
751This is the \fItype\fR argument passed to the \fBadd\fR widget
752method when the entry was created, such as \fBcommand\fR
753or \fBseparator\fR, or \fBtearoff\fR for a tear-off entry.
754.IP "\fI$menu\fR\->\fBunpost\fR" 4
755.IX Item "$menu->unpost"
756Unmap the window so that it is no longer displayed. If a
757lower-level cascaded menu is posted, unpost that menu. Returns an
758empty string. This method does not work on Windows and the
759Macintosh, as those platforms have their own way of unposting menus.
760.IP "\fI$menu\fR\->\fByposition\fR(\fIindex\fR)" 4
761.IX Item "$menu->yposition(index)"
762Returns a decimal string giving the y\-coordinate within the menu
763window of the topmost pixel in the entry specified by \fIindex\fR.
764.SH "MENU CONFIGURATIONS"
765.IX Header "MENU CONFIGURATIONS"
766The default bindings support four different ways of using menus:
767.IP "\fBPulldown Menus in Menubar\fR" 4
768.IX Item "Pulldown Menus in Menubar"
769This is the most command case. You create a menu widget that will become the
770menu bar. You then add cascade entries to this menu, specifying the
771pull down menus you wish to use in your menu bar. You then create all
772of the pulldowns. Once you have done this, specify the menu using the
773\&\fB\-menu\fR option of the toplevel's method. See the
774\&\fBtoplevel\fR manual entry for details.
775.IP "\fBPulldown Menus in Menu Buttons\fR" 4
776.IX Item "Pulldown Menus in Menu Buttons"
777This is the compatable way to do menu bars. You create one menubutton
778widget for each top-level menu, and typically you arrange a series of
779menubuttons in a row in a menubar window. You also create the top-level menus
780and any cascaded submenus, and tie them together with \fB\-menu\fR
781options in menubuttons and cascade menu entries. The top-level menu must
782be a child of the menubutton, and each submenu must be a child of the
783menu that refers to it. Once you have done this, the default bindings
784will allow users to traverse and invoke the tree of menus via its
785menubutton; see the \fBmenubutton\fR documentation for details.
786.IP "\fBPopup Menus\fR" 4
787.IX Item "Popup Menus"
788Popup menus typically post in response to a mouse button press or
789keystroke. You create the popup menus and any cascaded submenus,
790then you call the \fBPost\fR method at the appropriate time
791to post the top-level menu.
792.Sp
793\&\fI$menu\fR\->\fBPost\fR(\fI$x\fR,\fI$y\fR?,\fI$entry\fR?)
794.Sp
795\&\fI$x\fR and \fI$y\fR are the root window coordinates at which the \fI$menu\fR
796will be displayed. If \fI$entry\fR is specified then that entry is centred
797on that point, otherwise the top-left corner of the \fI$menu\fR is placed
798at that point.
799.Sp
800\&\fBMenu\fR also inherits methods from Tk::Wm and so the method
801\&\fBPopup\fR can be used to position menu relative to other windows, the
802mouse cursor or the screen.
803.IP "\fBOption Menus\fR" 4
804.IX Item "Option Menus"
805An option menu consists of a menubutton with an associated menu
806that allows you to select one of several values. The current value
807is displayed in the menubutton and is also stored in a global
808variable. Use the Tk::Optionmenu class to create option
809menubuttons and their menus.
810.IP "\fBTorn-off Menus\fR" 4
811.IX Item "Torn-off Menus"
812You create a torn-off menu by invoking the tear-off entry at
813the top of an existing menu. The default bindings will create a new menu
814that is a copy of the original menu and leave it permanently
815posted as a top-level window. The torn-off menu behaves just
816the same as the original menu.
817.SH "DEFAULT BINDINGS"
818.IX Header "DEFAULT BINDINGS"
819Tk automatically creates class bindings for menus that give them
820the following default behavior:
821.IP "[1]" 4
822.IX Item "[1]"
823When the mouse enters a menu, the entry underneath the mouse
824cursor activates; as the mouse moves around the menu, the active
825entry changes to track the mouse.
826.IP "[2]" 4
827.IX Item "[2]"
828When the mouse leaves a menu all of the entries in the menu
829deactivate, except in the special case where the mouse moves from
830a menu to a cascaded submenu.
831.IP "[3]" 4
832.IX Item "[3]"
833When a button is released over a menu, the active entry (if any) is invoked.
834The menu also unposts unless it is a torn-off menu.
835.IP "[4]" 4
836.IX Item "[4]"
837The Space and Return keys invoke the active entry and
838unpost the menu.
839.IP "[5]" 4
840.IX Item "[5]"
841If any of the entries in a menu have letters underlined with
842with \fB\-underline\fR option, then pressing one of the underlined
843letters (or its upper-case or lower-case equivalent) invokes that
844entry and unposts the menu.
845.IP "[6]" 4
846.IX Item "[6]"
847The Escape key aborts a menu selection in progress without invoking any
848entry. It also unposts the menu unless it is a torn-off menu.
849.IP "[7]" 4
850.IX Item "[7]"
851The Up and Down keys activate the next higher or lower entry
852in the menu. When one end of the menu is reached, the active
853entry wraps around to the other end.
854.IP "[8]" 4
855.IX Item "[8]"
856The Left key moves to the next menu to the left.
857If the current menu is a cascaded submenu, then the submenu is
858unposted and the current menu entry becomes the cascade entry
859in the parent.
860If the current menu is a top-level menu posted from a
861menubutton, then the current menubutton is unposted and the
862next menubutton to the left is posted.
863Otherwise the key has no effect.
864The left-right order of menubuttons is determined by their stacking
865order: Tk assumes that the lowest menubutton (which by default
866is the first one created) is on the left.
867.IP "[9]" 4
868.IX Item "[9]"
869The Right key moves to the next menu to the right.
870If the current entry is a cascade entry, then the submenu is
871posted and the current menu entry becomes the first entry
872in the submenu.
873Otherwise, if the current menu was posted from a
874menubutton, then the current menubutton is unposted and the
875next menubutton to the right is posted.
876.Sp
877Disabled menu entries are non\-responsive: they don't activate and
878they ignore mouse button presses and releases.
879.Sp
880The behavior of menus can be changed by defining new bindings for
881individual widgets or by redefining the class bindings.
882.SH "BUGS"
883.IX Header "BUGS"
884At present it isn't possible to use the
885option database to specify values for the options to individual
886entries.
887.SH "SEE ALSO"
888.IX Header "SEE ALSO"
889Tk::callbacks
890.SH "KEYWORDS"
891.IX Header "KEYWORDS"
892menu, widget