1menu(n) Tk Built-In Commands menu(n)
2
3
4
5______________________________________________________________________________
6
8 menu, tk_menuSetFocus - Create and manipulate menu widgets
9
11 menu pathName ?options?
12 tk_menuSetFocus pathName
13
15 -activebackground -borderwidth -foreground
16 -activeborderwidth -cursor -relief
17 -activeforeground -disabledforeground -takefocus
18 -background -font
19
20 See the options manual entry for details on the standard options.
21
23 [-postcommand postCommand] If this option is specified then it provides
24 a Tcl command to execute each time the menu is posted. The command is
25 invoked by the post widget command before posting the menu. Note that
26 in Tk 8.0 on Macintosh and Windows, all post-commands in a system of
27 menus are executed before any of those menus are posted. This is due
28 to the limitations in the individual platforms' menu managers.
29 [-selectcolor selectColor] For menu entries that are check buttons or
30 radio buttons, this option specifies the color to display in the indi‐
31 cator when the check button or radio button is selected.
32 [-tearoff tearOff] This option must have a proper boolean value, which
33 specifies whether or not the menu should include a tear-off entry at
34 the top. If so, it will exist as entry 0 of the menu and the other
35 entries will number starting at 1. The default menu bindings arrange
36 for the menu to be torn off when the tear-off entry is invoked.
37 [-tearoffcommand tearOffCommand] If this option has a non-empty value,
38 then it specifies a Tcl command to invoke whenever the menu is torn
39 off. The actual command will consist of the value of this option, fol‐
40 lowed by a space, followed by the name of the menu window, followed by
41 a space, followed by the name of the name of the torn off menu window.
42 For example, if the option's value is “a b” and menu .x.y is torn off
43 to create a new menu .x.tearoff1, then the command “a b .x.y
44 .x.tearoff1” will be invoked. [-title title] The string will be used
45 to title the window created when this menu is torn off. If the title is
46 NULL, then the window will have the title of the menubutton or the text
47 of the cascade item from which this menu was invoked. [-type type]
48 This option can be one of menubar, tearoff, or normal, and is set when
49 the menu is created. While the string returned by the configuration
50 database will change if this option is changed, this does not affect
51 the menu widget's behavior. This is used by the cloning mechanism and
52 is not normally set outside of the Tk library.
53_________________________________________________________________
54
56 The menu command creates a new top-level window (given by the pathName
57 argument) and makes it into a menu widget. Additional options,
58 described above, may be specified on the command line or in the option
59 database to configure aspects of the menu such as its colors and font.
60 The menu command returns its pathName argument. At the time this com‐
61 mand is invoked, there must not exist a window named pathName, but
62 pathName's parent must exist.
63
64 A menu is a widget that displays a collection of one-line entries
65 arranged in one or more columns. There exist several different types
66 of entries, each with different properties. Entries of different types
67 may be combined in a single menu. Menu entries are not the same as
68 entry widgets. In fact, menu entries are not even distinct widgets;
69 the entire menu is one widget.
70
71 Menu entries are displayed with up to three separate fields. The main
72 field is a label in the form of a text string, a bitmap, or an image,
73 controlled by the -label, -bitmap, and -image options for the entry.
74 If the -accelerator option is specified for an entry then a second
75 textual field is displayed to the right of the label. The accelerator
76 typically describes a keystroke sequence that may be typed in the
77 application to cause the same result as invoking the menu entry. The
78 third field is an indicator. The indicator is present only for check‐
79 button or radiobutton entries. It indicates whether the entry is
80 selected or not, and is displayed to the left of the entry's string.
81
82 In normal use, an entry becomes active (displays itself differently)
83 whenever the mouse pointer is over the entry. If a mouse button is
84 released over the entry then the entry is invoked. The effect of invo‐
85 cation is different for each type of entry; these effects are described
86 below in the sections on individual entries.
87
88 Entries may be disabled, which causes their labels and accelerators to
89 be displayed with dimmer colors. The default menu bindings will not
90 allow a disabled entry to be activated or invoked. Disabled entries
91 may be re-enabled, at which point it becomes possible to activate and
92 invoke them again.
93
94 Whenever a menu's active entry is changed, a <<MenuSelect>> virtual
95 event is send to the menu. The active item can then be queried from the
96 menu, and an action can be taken, such as setting context-sensitive
97 help text for the entry.
98
100 COMMAND ENTRIES
101 The most common kind of menu entry is a command entry, which behaves
102 much like a button widget. When a command entry is invoked, a Tcl com‐
103 mand is executed. The Tcl command is specified with the -command
104 option.
105
106 SEPARATOR ENTRIES
107 A separator is an entry that is displayed as a horizontal dividing
108 line. A separator may not be activated or invoked, and it has no
109 behavior other than its display appearance.
110
111 CHECKBUTTON ENTRIES
112 A checkbutton menu entry behaves much like a checkbutton widget. When
113 it is invoked it toggles back and forth between the selected and dese‐
114 lected states. When the entry is selected, a particular value is
115 stored in a particular global variable (as determined by the -onvalue
116 and -variable options for the entry); when the entry is deselected
117 another value (determined by the -offvalue option) is stored in the
118 global variable. An indicator box is displayed to the left of the
119 label in a checkbutton entry. If the entry is selected then the indi‐
120 cator's center is displayed in the color given by the -selectcolor
121 option for the entry; otherwise the indicator's center is displayed in
122 the background color for the menu. If a -command option is specified
123 for a checkbutton entry, then its value is evaluated as a Tcl command
124 each time the entry is invoked; this happens after toggling the
125 entry's selected state.
126
127 RADIOBUTTON ENTRIES
128 A radiobutton menu entry behaves much like a radiobutton widget.
129 Radiobutton entries are organized in groups of which only one entry may
130 be selected at a time. Whenever a particular entry becomes selected it
131 stores a particular value into a particular global variable (as deter‐
132 mined by the -value and -variable options for the entry). This action
133 causes any previously-selected entry in the same group to deselect
134 itself. Once an entry has become selected, any change to the entry's
135 associated variable will cause the entry to deselect itself. Grouping
136 of radiobutton entries is determined by their associated variables: if
137 two entries have the same associated variable then they are in the same
138 group. An indicator diamond is displayed to the left of the label in
139 each radiobutton entry. If the entry is selected then the indicator's
140 center is displayed in the color given by the -selectcolor option for
141 the entry; otherwise the indicator's center is displayed in the back‐
142 ground color for the menu. If a -command option is specified for a
143 radiobutton entry, then its value is evaluated as a Tcl command each
144 time the entry is invoked; this happens after selecting the entry.
145
146 CASCADE ENTRIES
147 A cascade entry is one with an associated menu (determined by the -menu
148 option). Cascade entries allow the construction of cascading menus.
149 The postcascade widget command can be used to post and unpost the asso‐
150 ciated menu just next to of the cascade entry. The associated menu
151 must be a child of the menu containing the cascade entry (this is
152 needed in order for menu traversal to work correctly).
153
154 A cascade entry posts its associated menu by invoking a Tcl command of
155 the form
156 menu post x y
157 where menu is the path name of the associated menu, and x and y are the
158 root-window coordinates of the upper-right corner of the cascade entry.
159 On Unix, the lower-level menu is unposted by executing a Tcl command
160 with the form
161 menu unpost
162 where menu is the name of the associated menu. On other platforms, the
163 platform's native code takes care of unposting the menu.
164
165 If a -command option is specified for a cascade entry then it is evalu‐
166 ated as a Tcl command whenever the entry is invoked. This is not sup‐
167 ported on Windows.
168
169 TEAR-OFF ENTRIES
170 A tear-off entry appears at the top of the menu if enabled with the
171 tearOff option. It is not like other menu entries in that it cannot be
172 created with the add widget command and cannot be deleted with the
173 delete widget command. When a tear-off entry is created it appears as
174 a dashed line at the top of the menu. Under the default bindings,
175 invoking the tear-off entry causes a torn-off copy to be made of the
176 menu and all of its submenus.
177
179 Any menu can be set as a menubar for a toplevel window (see toplevel
180 command for syntax). On the Macintosh, whenever the toplevel is in
181 front, this menu's cascade items will appear in the menubar across the
182 top of the main monitor. On Windows and Unix, this menu's items will be
183 displayed in a menubar across the top of the window. These menus will
184 behave according to the interface guidelines of their platforms. For
185 every menu set as a menubar, a clone menu is made. See the CLONES sec‐
186 tion for more information.
187
188 As noted, menubars may behave differently on different platforms. One
189 example of this concerns the handling of checkbuttons and radiobuttons
190 within the menu. While it is permitted to put these menu elements on
191 menubars, they may not be drawn with indicators on some platforms, due
192 to system restrictions.
193
194 SPECIAL MENUS IN MENUBARS
195 Certain menus in a menubar will be treated specially. On the Macin‐
196 tosh, access to the special Application and Help menus is provided. On
197 Windows, access to the Windows System menu in each window is provided.
198 On X Windows, a special right-justified help menu is provided. In all
199 cases, these menus must be created with the command name of the menubar
200 menu concatenated with the special name. So for a menubar named
201 .menubar, on the Macintosh, the special menus would be .menubar.apple
202 and .menubar.help; on Windows, the special menu would be .menubar.sys‐
203 tem; on X Windows, the help menu would be .menubar.help.
204
205 When Tk sees a .menubar.apple menu on the Macintosh, that menu's con‐
206 tents make up the first items of the Application menu whenever the win‐
207 dow containing the menubar is in front. After all of the Tk-defined
208 items, the menu will have a separator, followed by all standard Appli‐
209 cation menu items.
210
211 When Tk sees a Help menu on the Macintosh, the menu's contents are
212 appended to the standard Help menu on the right of the user's menubar
213 whenever the window's menubar is in front. The first items in the menu
214 are provided by Mac OS X.
215
216 When Tk sees a System menu on Windows, its items are appended to the
217 system menu that the menubar is attached to. This menu has an icon rep‐
218 resenting a spacebar, and can be invoked with the mouse or by typing
219 Alt+Spacebar. Due to limitations in the Windows API, any font changes,
220 colors, images, bitmaps, or tearoff images will not appear in the sys‐
221 tem menu.
222
223 When Tk see a Help menu on X Windows, the menu is moved to be last in
224 the menubar and is right justified.
225
227 When a menu is set as a menubar for a toplevel window, or when a menu
228 is torn off, a clone of the menu is made. This clone is a menu widget
229 in its own right, but it is a child of the original. Changes in the
230 configuration of the original are reflected in the clone. Additionally,
231 any cascades that are pointed to are also cloned so that menu traversal
232 will work right. Clones are destroyed when either the tearoff or
233 menubar goes away, or when the original menu is destroyed.
234
236 The menu command creates a new Tcl command whose name is pathName.
237 This command may be used to invoke various operations on the widget.
238 It has the following general form:
239 pathName option ?arg arg ...?
240 Option and the args determine the exact behavior of the command.
241
242 Many of the widget commands for a menu take as one argument an indica‐
243 tor of which entry of the menu to operate on. These indicators are
244 called indexes and may be specified in any of the following forms:
245
246 number Specifies the entry numerically, where 0 corresponds to the
247 top-most entry of the menu, 1 to the entry below it, and so
248 on.
249
250 active Indicates the entry that is currently active. If no entry
251 is active then this form is equivalent to none. This form
252 may not be abbreviated.
253
254 end Indicates the bottommost entry in the menu. If there are
255 no entries in the menu then this form is equivalent to
256 none. This form may not be abbreviated.
257
258 last Same as end.
259
260 none Indicates “no entry at all”; this is used most commonly
261 with the activate option to deactivate all the entries in
262 the menu. In most cases the specification of none causes
263 nothing to happen in the widget command. This form may not
264 be abbreviated.
265
266 @number In this form, number is treated as a y-coordinate in the
267 menu's window; the entry closest to that y-coordinate is
268 used. For example, “@0” indicates the top-most entry in
269 the window.
270
271 pattern If the index does not satisfy one of the above forms then
272 this form is used. Pattern is pattern-matched against the
273 label of each entry in the menu, in order from the top
274 down, until a matching entry is found. The rules of
275 Tcl_StringMatch are used.
276
277 The following widget commands are possible for menu widgets:
278
279 pathName activate index
280 Change the state of the entry indicated by index to active and
281 redisplay it using its active colors. Any previously-active
282 entry is deactivated. If index is specified as none, or if the
283 specified entry is disabled, then the menu ends up with no
284 active entry. Returns an empty string.
285
286 pathName add type ?option value option value ...?
287 Add a new entry to the bottom of the menu. The new entry's type
288 is given by type and must be one of cascade, checkbutton, com‐
289 mand, radiobutton, or separator, or a unique abbreviation of one
290 of the above. If additional arguments are present, they specify
291 any of the following options:
292
293 -activebackground value
294 Specifies a background color to use for displaying this
295 entry when it is active. If this option is specified as
296 an empty string (the default), then the activeBackground
297 option for the overall menu is used. If the tk_strictMo‐
298 tif variable has been set to request strict Motif compli‐
299 ance, then this option is ignored and the -background
300 option is used in its place. This option is not avail‐
301 able for separator or tear-off entries.
302
303 -activeforeground value
304 Specifies a foreground color to use for displaying this
305 entry when it is active. If this option is specified as
306 an empty string (the default), then the activeForeground
307 option for the overall menu is used. This option is not
308 available for separator or tear-off entries.
309
310 -accelerator value
311 Specifies a string to display at the right side of the
312 menu entry. Normally describes an accelerator keystroke
313 sequence that may be typed to invoke the same function as
314 the menu entry. This option is not available for separa‐
315 tor or tear-off entries.
316
317 -background value
318 Specifies a background color to use for displaying this
319 entry when it is in the normal state (neither active nor
320 disabled). If this option is specified as an empty
321 string (the default), then the background option for the
322 overall menu is used. This option is not available for
323 separator or tear-off entries.
324
325 -bitmap value
326 Specifies a bitmap to display in the menu instead of a
327 textual label, in any of the forms accepted by Tk_Get‐
328 Bitmap. This option overrides the -label option (as con‐
329 trolled by the -compound option) but may be reset to an
330 empty string to enable a textual label to be displayed.
331 If a -image option has been specified, it overrides -bit‐
332 map. This option is not available for separator or tear-
333 off entries.
334
335 -columnbreak value
336 When this option is zero, the entry appears below the
337 previous entry. When this option is one, the entry
338 appears at the top of a new column in the menu.
339
340 -command value
341 Specifies a Tcl command to execute when the menu entry is
342 invoked. Not available for separator or tear-off
343 entries.
344
345 -compound value
346 Specifies whether the menu entry should display both an
347 image and text, and if so, where the image should be
348 placed relative to the text. Valid values for this
349 option are bottom, center, left, none, right and top.
350 The default value is none, meaning that the button will
351 display either an image or text, depending on the values
352 of the -image and -bitmap options.
353
354 -font value
355 Specifies the font to use when drawing the label or
356 accelerator string in this entry. If this option is
357 specified as an empty string (the default) then the font
358 option for the overall menu is used. This option is not
359 available for separator or tear-off entries.
360
361 -foreground value
362 Specifies a foreground color to use for displaying this
363 entry when it is in the normal state (neither active nor
364 disabled). If this option is specified as an empty
365 string (the default), then the foreground option for the
366 overall menu is used. This option is not available for
367 separator or tear-off entries.
368
369 -hidemargin value
370 Specifies whether the standard margins should be drawn
371 for this menu entry. This is useful when creating palette
372 with images in them, i.e., color palettes, pattern pal‐
373 ettes, etc. 1 indicates that the margin for the entry is
374 hidden; 0 means that the margin is used.
375
376 -image value
377 Specifies an image to display in the menu instead of a
378 text string or bitmap. The image must have been created
379 by some previous invocation of image create. This option
380 overrides the -label and -bitmap options (as controlled
381 by the -compound option) but may be reset to an empty
382 string to enable a textual or bitmap label to be dis‐
383 played. This option is not available for separator or
384 tear-off entries.
385
386 -indicatoron value
387 Available only for checkbutton and radiobutton entries.
388 Value is a boolean that determines whether or not the
389 indicator should be displayed.
390
391 -label value
392 Specifies a string to display as an identifying label in
393 the menu entry. Not available for separator or tear-off
394 entries.
395
396 -menu value
397 Available only for cascade entries. Specifies the path
398 name of the submenu associated with this entry. The sub‐
399 menu must be a child of the menu.
400
401 -offvalue value
402 Available only for checkbutton entries. Specifies the
403 value to store in the entry's associated variable when
404 the entry is deselected.
405
406 -onvalue value
407 Available only for checkbutton entries. Specifies the
408 value to store in the entry's associated variable when
409 the entry is selected.
410
411 -selectcolor value
412 Available only for checkbutton and radiobutton entries.
413 Specifies the color to display in the indicator when the
414 entry is selected. If the value is an empty string (the
415 default) then the selectColor option for the menu deter‐
416 mines the indicator color.
417
418 -selectimage value
419 Available only for checkbutton and radiobutton entries.
420 Specifies an image to display in the entry (in place of
421 the -image option) when it is selected. Value is the
422 name of an image, which must have been created by some
423 previous invocation of image create. This option is
424 ignored unless the -image option has been specified.
425
426 -state value
427 Specifies one of three states for the entry: normal,
428 active, or disabled. In normal state the entry is dis‐
429 played using the foreground option for the menu and the
430 background option from the entry or the menu. The active
431 state is typically used when the pointer is over the
432 entry. In active state the entry is displayed using the
433 activeForeground option for the menu along with the
434 activebackground option from the entry. Disabled state
435 means that the entry should be insensitive: the default
436 bindings will refuse to activate or invoke the entry. In
437 this state the entry is displayed according to the dis‐
438 abledForeground option for the menu and the background
439 option from the entry. This option is not available for
440 separator entries.
441
442 -underline value
443 Specifies the integer index of a character to underline
444 in the entry. This option is also queried by the default
445 bindings and used to implement keyboard traversal. 0
446 corresponds to the first character of the text displayed
447 in the entry, 1 to the next character, and so on. If a
448 bitmap or image is displayed in the entry then this
449 option is ignored. This option is not available for sep‐
450 arator or tear-off entries.
451
452 -value value
453 Available only for radiobutton entries. Specifies the
454 value to store in the entry's associated variable when
455 the entry is selected. If an empty string is specified,
456 then the -label option for the entry as the value to
457 store in the variable.
458
459 -variable value
460 Available only for checkbutton and radiobutton entries.
461 Specifies the name of a global value to set when the
462 entry is selected. For checkbutton entries the variable
463 is also set when the entry is deselected. For radiobut‐
464 ton entries, changing the variable causes the currently-
465 selected entry to deselect itself.
466
467 The add widget command returns an empty string.
468
469 pathName cget option
470 Returns the current value of the configuration option given by
471 option. Option may have any of the values accepted by the menu
472 command.
473
474 pathName clone newPathname ?cloneType?
475 Makes a clone of the current menu named newPathName. This clone
476 is a menu in its own right, but any changes to the clone are
477 propagated to the original menu and vice versa. cloneType can be
478 normal, menubar, or tearoff. Should not normally be called out‐
479 side of the Tk library. See the CLONES section for more informa‐
480 tion.
481
482 pathName configure ?option? ?value option value ...?
483 Query or modify the configuration options of the widget. If no
484 option is specified, returns a list describing all of the avail‐
485 able options for pathName (see Tk_ConfigureInfo for information
486 on the format of this list). If option is specified with no
487 value, then the command returns a list describing the one named
488 option (this list will be identical to the corresponding sublist
489 of the value returned if no option is specified). If one or
490 more option-value pairs are specified, then the command modifies
491 the given widget option(s) to have the given value(s); in this
492 case the command returns an empty string. Option may have any
493 of the values accepted by the menu command.
494
495 pathName delete index1 ?index2?
496 Delete all of the menu entries between index1 and index2 inclu‐
497 sive. If index2 is omitted then it defaults to index1.
498 Attempts to delete a tear-off menu entry are ignored (instead,
499 you should change the tearOff option to remove the tear-off
500 entry).
501
502 pathName entrycget index option
503 Returns the current value of a configuration option for the
504 entry given by index. Option may have any of the values
505 accepted by the add widget command.
506
507 pathName entryconfigure index ?options?
508 This command is similar to the configure command, except that it
509 applies to the options for an individual entry, whereas config‐
510 ure applies to the options for the menu as a whole. Options may
511 have any of the values accepted by the add widget command. If
512 options are specified, options are modified as indicated in the
513 command and the command returns an empty string. If no options
514 are specified, returns a list describing the current options for
515 entry index (see Tk_ConfigureInfo for information on the format
516 of this list).
517
518 pathName index index
519 Returns the numerical index corresponding to index, or none if
520 index was specified as none.
521
522 pathName insert index type ?option value option value ...?
523 Same as the add widget command except that it inserts the new
524 entry just before the entry given by index, instead of appending
525 to the end of the menu. The type, option, and value arguments
526 have the same interpretation as for the add widget command. It
527 is not possible to insert new menu entries before the tear-off
528 entry, if the menu has one.
529
530 pathName invoke index
531 Invoke the action of the menu entry. See the sections on the
532 individual entries above for details on what happens. If the
533 menu entry is disabled then nothing happens. If the entry has a
534 command associated with it then the result of that command is
535 returned as the result of the invoke widget command. Otherwise
536 the result is an empty string. Note: invoking a menu entry
537 does not automatically unpost the menu; the default bindings
538 normally take care of this before invoking the invoke widget
539 command.
540
541 pathName post x y
542 Arrange for the menu to be displayed on the screen at the root-
543 window coordinates given by x and y. These coordinates are
544 adjusted if necessary to guarantee that the entire menu is visi‐
545 ble on the screen. This command normally returns an empty
546 string. If the postCommand option has been specified, then its
547 value is executed as a Tcl script before posting the menu and
548 the result of that script is returned as the result of the post
549 widget command. If an error returns while executing the com‐
550 mand, then the error is returned without posting the menu.
551
552 pathName postcascade index
553 Posts the submenu associated with the cascade entry given by
554 index, and unposts any previously posted submenu. If index does
555 not correspond to a cascade entry, or if pathName is not posted,
556 the command has no effect except to unpost any currently posted
557 submenu.
558
559 pathName type index
560 Returns the type of the menu entry given by index. This is the
561 type argument passed to the add widget command when the entry
562 was created, such as command or separator, or tearoff for a
563 tear-off entry.
564
565 pathName unpost
566 Unmap the window so that it is no longer displayed. If a lower-
567 level cascaded menu is posted, unpost that menu. Returns an
568 empty string. This subcommand does not work on Windows and the
569 Macintosh, as those platforms have their own way of unposting
570 menus.
571
572 pathName xposition index
573 Returns a decimal string giving the x-coordinate within the menu │
574 window of the leftmost pixel in the entry specified by index.
575
576 pathName yposition index
577 Returns a decimal string giving the y-coordinate within the menu
578 window of the topmost pixel in the entry specified by index.
579
581 The default bindings support four different ways of using menus:
582
583 Pulldown Menus in Menubar
584 This is the most common case. You create a menu widget that will
585 become the menu bar. You then add cascade entries to this menu,
586 specifying the pull down menus you wish to use in your menu bar.
587 You then create all of the pulldowns. Once you have done this,
588 specify the menu using the -menu option of the toplevel's widget
589 command. See the toplevel manual entry for details.
590
591 Pulldown Menus in Menu Buttons
592 This is the compatible way to do menu bars. You create one
593 menubutton widget for each top-level menu, and typically you
594 arrange a series of menubuttons in a row in a menubar window.
595 You also create the top-level menus and any cascaded submenus,
596 and tie them together with -menu options in menubuttons and cas‐
597 cade menu entries. The top-level menu must be a child of the
598 menubutton, and each submenu must be a child of the menu that
599 refers to it. Once you have done this, the default bindings
600 will allow users to traverse and invoke the tree of menus via
601 its menubutton; see the menubutton manual entry for details.
602
603 Popup Menus
604 Popup menus typically post in response to a mouse button press
605 or keystroke. You create the popup menus and any cascaded sub‐
606 menus, then you call the tk_popup procedure at the appropriate
607 time to post the top-level menu.
608
609 Option Menus
610 An option menu consists of a menubutton with an associated menu
611 that allows you to select one of several values. The current
612 value is displayed in the menubutton and is also stored in a
613 global variable. Use the tk_optionMenu procedure to create
614 option menubuttons and their menus.
615
616 Torn-off Menus
617 You create a torn-off menu by invoking the tear-off entry at the
618 top of an existing menu. The default bindings will create a new
619 menu that is a copy of the original menu and leave it perma‐
620 nently posted as a top-level window. The torn-off menu behaves
621 just the same as the original menu.
622
624 Tk automatically creates class bindings for menus that give them the
625 following default behavior:
626
627 [1] When the mouse enters a menu, the entry underneath the mouse
628 cursor activates; as the mouse moves around the menu, the
629 active entry changes to track the mouse.
630
631 [2] When the mouse leaves a menu all of the entries in the menu
632 deactivate, except in the special case where the mouse moves
633 from a menu to a cascaded submenu.
634
635 [3] When a button is released over a menu, the active entry (if any)
636 is invoked. The menu also unposts unless it is a torn-off menu.
637
638 [4] The Space and Return keys invoke the active entry and unpost the
639 menu.
640
641 [5] If any of the entries in a menu have letters underlined with the
642 -underline option, then pressing one of the underlined letters
643 (or its upper-case or lower-case equivalent) invokes that entry
644 and unposts the menu.
645
646 [6] The Escape key aborts a menu selection in progress without
647 invoking any entry. It also unposts the menu unless it is a
648 torn-off menu.
649
650 [7] The Up and Down keys activate the next higher or lower entry in
651 the menu. When one end of the menu is reached, the active entry
652 wraps around to the other end.
653
654 [8] The Left key moves to the next menu to the left. If the current
655 menu is a cascaded submenu, then the submenu is unposted and the
656 current menu entry becomes the cascade entry in the parent. If
657 the current menu is a top-level menu posted from a menubutton,
658 then the current menubutton is unposted and the next menubutton
659 to the left is posted. Otherwise the key has no effect. The
660 left-right order of menubuttons is determined by their stacking
661 order: Tk assumes that the lowest menubutton (which by default
662 is the first one created) is on the left.
663
664 [9] The Right key moves to the next menu to the right. If the cur‐
665 rent entry is a cascade entry, then the submenu is posted and
666 the current menu entry becomes the first entry in the submenu.
667 Otherwise, if the current menu was posted from a menubutton,
668 then the current menubutton is unposted and the next menubutton
669 to the right is posted.
670
671 Disabled menu entries are non-responsive: they do not activate and
672 they ignore mouse button presses and releases.
673
674 Several of the bindings make use of the command tk_menuSetFocus. It
675 saves the current focus and sets the focus to its pathName argument,
676 which is a menu widget.
677
678 The behavior of menus can be changed by defining new bindings for indi‐
679 vidual widgets or by redefining the class bindings.
680
682 At present it is not possible to use the option database to specify
683 values for the options to individual entries.
684
686 bind(n), menubutton(n), ttk::menubutton(n), toplevel(n)
687
689 menu, widget
690
691
692
693Tk 4.1 menu(n)