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