| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| 2 |
<html> |
| 3 |
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ --> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 |
<title>menu (GCL TK Manual)</title> |
| 7 |
|
| 8 |
<meta name="description" content="menu (GCL TK Manual)"> |
| 9 |
<meta name="keywords" content="menu (GCL TK Manual)"> |
| 10 |
<meta name="resource-type" content="document"> |
| 11 |
<meta name="distribution" content="global"> |
| 12 |
<meta name="Generator" content="makeinfo"> |
| 13 |
<link href="index.html" rel="start" title="Top"> |
| 14 |
<link href="wm.html#SEC_Contents" rel="contents" title="Table of Contents"> |
| 15 |
<link href="Widgets.html" rel="up" title="Widgets"> |
| 16 |
<link href="scrollbar.html" rel="next" title="scrollbar"> |
| 17 |
<link href="canvas.html" rel="prev" title="canvas"> |
| 18 |
<style type="text/css"> |
| 19 |
<!-- |
| 20 |
a.summary-letter {text-decoration: none} |
| 21 |
blockquote.indentedblock {margin-right: 0em} |
| 22 |
div.display {margin-left: 3.2em} |
| 23 |
div.example {margin-left: 3.2em} |
| 24 |
div.lisp {margin-left: 3.2em} |
| 25 |
kbd {font-style: oblique} |
| 26 |
pre.display {font-family: inherit} |
| 27 |
pre.format {font-family: inherit} |
| 28 |
pre.menu-comment {font-family: serif} |
| 29 |
pre.menu-preformatted {font-family: serif} |
| 30 |
span.nolinebreak {white-space: nowrap} |
| 31 |
span.roman {font-family: initial; font-weight: normal} |
| 32 |
span.sansserif {font-family: sans-serif; font-weight: normal} |
| 33 |
ul.no-bullet {list-style: none} |
| 34 |
--> |
| 35 |
</style> |
| 36 |
|
| 37 |
|
| 38 |
</head> |
| 39 |
|
| 40 |
<body lang="en"> |
| 41 |
<span id="menu"></span><div class="header"> |
| 42 |
<p> |
| 43 |
Next: <a href="scrollbar.html" accesskey="n" rel="next">scrollbar</a>, Previous: <a href="canvas.html" accesskey="p" rel="prev">canvas</a>, Up: <a href="Widgets.html" accesskey="u" rel="up">Widgets</a> [<a href="wm.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> |
| 44 |
</div> |
| 45 |
<hr> |
| 46 |
<span id="menu-1"></span><h3 class="section">2.5 menu</h3> |
| 47 |
|
| 48 |
<p>menu \- Create and manipulate menu widgets |
| 49 |
</p><span id="Synopsis-4"></span><h4 class="unnumberedsubsec">Synopsis</h4> |
| 50 |
<p><b>menu</b><i> </i><i>pathName </i><span class="roman">?</span><i>options</i>? |
| 51 |
</p><span id="Standard-Options-4"></span><h4 class="unnumberedsubsec">Standard Options</h4> |
| 52 |
|
| 53 |
|
| 54 |
<div class="example"> |
| 55 |
<pre class="example">activeBackground background disabledForeground |
| 56 |
activeBorderWidth borderWidth font |
| 57 |
activeForeground cursor foreground |
| 58 |
</pre></div> |
| 59 |
|
| 60 |
|
| 61 |
<p>See <a href="options.html">options</a>, for more information. |
| 62 |
</p><span id="Arguments-for-Menu"></span><h4 class="unnumberedsubsec">Arguments for Menu</h4> |
| 63 |
|
| 64 |
|
| 65 |
<dl compact="compact"> |
| 66 |
<dt><code><b>:postcommand</b></code></dt> |
| 67 |
<dd><p align="right">Name=<code>"<b>postCommand</b><span class="roman">"</span> Class=<code>"</code><b>Command</b>"</code> |
| 68 |
</p><br> |
| 69 |
|
| 70 |
<p>If this option is specified then it provides a Tcl command to execute |
| 71 |
each time the menu is posted. The command is invoked by the <b>post</b> |
| 72 |
widget command before posting the menu. |
| 73 |
</p></dd> |
| 74 |
</dl> |
| 75 |
|
| 76 |
|
| 77 |
<dl compact="compact"> |
| 78 |
<dt><code><b>:selector</b></code></dt> |
| 79 |
<dd><p align="right">Name=<code>"<b>selector</b><span class="roman">"</span> Class=<code>"</code><b>Foreground</b>"</code> |
| 80 |
</p><br> |
| 81 |
|
| 82 |
<p>For menu entries that are check buttons or radio buttons, this option |
| 83 |
specifies the color to display in the selector when the check button |
| 84 |
or radio button is selected. |
| 85 |
</p></dd> |
| 86 |
</dl> |
| 87 |
|
| 88 |
<span id="Introduction-3"></span><h4 class="unnumberedsubsec">Introduction</h4> |
| 89 |
|
| 90 |
<p>The <b>menu</b> command creates a new top-level window (given |
| 91 |
by the <i>pathName</i> argument) and makes it into a menu widget. |
| 92 |
Additional |
| 93 |
options, described above, may be specified on the command line |
| 94 |
or in the option database |
| 95 |
to configure aspects of the menu such as its colors and font. |
| 96 |
The <b>menu</b> command returns its |
| 97 |
<i>pathName</i> argument. At the time this command is invoked, |
| 98 |
there must not exist a window named <i>pathName</i>, but |
| 99 |
<i>pathName</i>’s parent must exist. |
| 100 |
</p> |
| 101 |
<p>A menu is a widget that displays a collection of one-line entries arranged |
| 102 |
in a column. There exist several different types of entries, |
| 103 |
each with different properties. Entries of different types may be |
| 104 |
combined in a single menu. Menu entries are not the same as |
| 105 |
entry widgets. In fact, menu entries are not even distinct widgets; |
| 106 |
the entire menu is one widget. |
| 107 |
</p> |
| 108 |
<p>Menu entries are displayed with up to three |
| 109 |
separate fields. The main field is a label in the form of text or |
| 110 |
a bitmap, which is determined by the <b>:label</b><span class="roman"> or </span><b>:bitmap</b> |
| 111 |
option for the entry. |
| 112 |
If the <b>:accelerator</b> option is specified for an entry then a second |
| 113 |
textual field is displayed to the right of the label. The accelerator |
| 114 |
typically describes a keystroke sequence that may be typed in the |
| 115 |
application to cause the same result as invoking the menu entry. |
| 116 |
The third field is a <i>selector</i>. The selector is present only for |
| 117 |
check-button or radio-button entries. It indicates whether the entry |
| 118 |
is selected or not, and is displayed to the left of the entry’s |
| 119 |
string. |
| 120 |
</p> |
| 121 |
<p>In normal use, an entry becomes active (displays itself differently) |
| 122 |
whenever the mouse pointer is over the entry. If a mouse |
| 123 |
button is released over the entry then the entry is <i>invoked</i>. |
| 124 |
The effect of invocation is different for each type of entry; |
| 125 |
these effects are described below in the sections on individual |
| 126 |
entries. |
| 127 |
</p> |
| 128 |
<p>Entries may be <i>disabled</i>, which causes their labels |
| 129 |
and accelerators to be displayed |
| 130 |
with dimmer colors. A disabled entry cannot be activated or invoked. |
| 131 |
Disabled entries may be re-enabled, at which point it becomes |
| 132 |
possible to activate and invoke them again. |
| 133 |
</p> |
| 134 |
<span id="Command-Entries"></span><h4 class="unnumberedsubsec">Command Entries</h4> |
| 135 |
|
| 136 |
<p>The most common kind of menu entry is a command entry, which |
| 137 |
behaves much like a button widget. When a command entry is |
| 138 |
invoked, a Tcl command is executed. The Tcl |
| 139 |
command is specified with the <b>:command</b> option. |
| 140 |
</p> |
| 141 |
<span id="Separator-Entries"></span><h4 class="unnumberedsubsec">Separator Entries</h4> |
| 142 |
|
| 143 |
<p>A separator is an entry that is displayed as a horizontal dividing |
| 144 |
line. A separator may not be activated or invoked, and it has |
| 145 |
no behavior other than its display appearance. |
| 146 |
</p> |
| 147 |
<span id="Check_002dButton-Entries"></span><h4 class="unnumberedsubsec">Check-Button Entries</h4> |
| 148 |
|
| 149 |
<p>A check-button menu entry behaves much like a check-button widget. |
| 150 |
When it is invoked it toggles back and forth between the selected |
| 151 |
and deselected states. When the entry is selected, a particular |
| 152 |
value is stored in a particular global variable (as determined by |
| 153 |
the <b>:onvalue</b><span class="roman"> and </span><b>:variable</b> options for the entry); when |
| 154 |
the entry is deselected another value (determined by the |
| 155 |
<b>:offvalue</b> option) is stored in the global variable. |
| 156 |
A selector box is displayed to the left of the label in a check-button |
| 157 |
entry. If the entry is selected then the box’s center is displayed |
| 158 |
in the color given by the <b>selector</b> option for the menu; |
| 159 |
otherwise the box’s center is displayed in the background color for |
| 160 |
the menu. If a <b>:command</b> option is specified for a check-button |
| 161 |
entry, then its value is evaluated as a Tcl command each time the entry |
| 162 |
is invoked; this happens after toggling the entry’s |
| 163 |
selected state. |
| 164 |
</p> |
| 165 |
<span id="Radio_002dButton-Entries"></span><h4 class="unnumberedsubsec">Radio-Button Entries</h4> |
| 166 |
|
| 167 |
<p>A radio-button menu entry behaves much like a radio-button widget. |
| 168 |
Radio-button entries are organized in groups of which only one |
| 169 |
entry may be selected at a time. Whenever a particular entry |
| 170 |
becomes selected it stores a particular value into a particular |
| 171 |
global variable (as determined by the <b>:value</b> and |
| 172 |
<b>:variable</b> options for the entry). This action |
| 173 |
causes any previously-selected entry in the same group |
| 174 |
to deselect itself. |
| 175 |
Once an entry has become selected, any change to the entry’s |
| 176 |
associated variable will cause the entry to deselect itself. |
| 177 |
Grouping of radio-button entries is determined by their |
| 178 |
associated variables: if two entries have the same associated |
| 179 |
variable then they are in the same group. |
| 180 |
A selector diamond is displayed to the left of the label in each |
| 181 |
radio-button entry. If the entry is selected then the diamond’s |
| 182 |
center is displayed in the color given by the <b>selector</b> option |
| 183 |
for the menu; |
| 184 |
otherwise the diamond’s center is displayed in the background color for |
| 185 |
the menu. If a <b>:command</b> option is specified for a radio-button |
| 186 |
entry, then its value is evaluated as a Tcl command each time the entry |
| 187 |
is invoked; this happens after selecting the entry. |
| 188 |
</p> |
| 189 |
<span id="Cascade-Entries"></span><h4 class="unnumberedsubsec">Cascade Entries</h4> |
| 190 |
|
| 191 |
<p>A cascade entry is one with an associated menu (determined |
| 192 |
by the <b>:menu</b> option). Cascade entries allow the construction |
| 193 |
of cascading menus. When the entry is activated, the |
| 194 |
associated menu is posted just to the right of the entry; |
| 195 |
that menu remains posted until the higher-level menu is unposted or |
| 196 |
until some other entry is activated in the higher-level menu. |
| 197 |
The associated menu should normally be a child of the menu containing |
| 198 |
the cascade entry, in order for menu traversal to work correctly. |
| 199 |
</p> |
| 200 |
<p>A cascade entry posts its associated menu by invoking a |
| 201 |
Tcl command of the form |
| 202 |
</p> |
| 203 |
<dl compact="compact"> |
| 204 |
<dt><i>menu</i><b> :post </b><i>x y</i></dt> |
| 205 |
<dd> |
| 206 |
|
| 207 |
|
| 208 |
<p>where <i>menu</i><span class="roman"> is the path name of the associated menu, </span><i>x</i> |
| 209 |
and <i>y</i> are the root-window coordinates of the upper-right |
| 210 |
corner of the cascade entry, and <i>group</i> is the name of the |
| 211 |
menu’s group (as determined in its last <b>post</b> widget command). |
| 212 |
The lower-level menu is unposted by executing a Tcl command with |
| 213 |
the form |
| 214 |
</p> |
| 215 |
</dd> |
| 216 |
<dt><i>menu</i><b>:unpost</b></dt> |
| 217 |
<dd><p>where <i>menu</i> is the name of the associated menu. |
| 218 |
</p></dd> |
| 219 |
</dl> |
| 220 |
|
| 221 |
<p>If a <b>:command</b> option is specified for a cascade entry then it is |
| 222 |
evaluated as a Tcl command each time the associated menu is posted (the |
| 223 |
evaluation occurs before the menu is posted). |
| 224 |
</p> |
| 225 |
<span id="A-Menu-Widget_0027s-Arguments"></span><h4 class="unnumberedsubsec">A Menu Widget’s Arguments</h4> |
| 226 |
|
| 227 |
<p>The <b>menu</b> command creates a new Tcl command whose |
| 228 |
name is <i>pathName</i>. This |
| 229 |
command may be used to invoke various |
| 230 |
operations on the widget. It has the following general form: |
| 231 |
</p> |
| 232 |
<dl compact="compact"> |
| 233 |
<dt><i>pathName option </i><span class="roman">?</span><i>arg arg ...</i>?</dt> |
| 234 |
<dd><p><i>Option</i><span class="roman"> and the </span><i>arg</i>s |
| 235 |
determine the exact behavior of the command. |
| 236 |
</p></dd> |
| 237 |
</dl> |
| 238 |
|
| 239 |
<p>Many of the widget commands for a menu take as one argument an |
| 240 |
indicator of which entry of the menu to operate on. These |
| 241 |
indicators are called <i>index</i>es and may be specified in |
| 242 |
any of the following forms: |
| 243 |
</p> |
| 244 |
<dl compact="compact"> |
| 245 |
<dt><i>number</i></dt> |
| 246 |
<dd><p>Specifies the entry numerically, where 0 corresponds |
| 247 |
to the top-most entry of the menu, 1 to the entry below it, and |
| 248 |
so on. |
| 249 |
</p></dd> |
| 250 |
<dt><b>active</b></dt> |
| 251 |
<dd><p>Indicates the entry that is currently active. If no entry is |
| 252 |
active then this form is equivalent to <b>none</b>. This form may |
| 253 |
not be abbreviated. |
| 254 |
</p></dd> |
| 255 |
<dt><b>last</b></dt> |
| 256 |
<dd><p>Indicates the bottommost entry in the menu. If there are no |
| 257 |
entries in the menu then this form is equivalent to <b>none</b>. |
| 258 |
This form may not be abbreviated. |
| 259 |
</p></dd> |
| 260 |
<dt><b>none</b></dt> |
| 261 |
<dd><p>Indicates “no entry at all”; this is used most commonly with |
| 262 |
the <b>activate</b> option to deactivate all the entries in the |
| 263 |
menu. In most cases the specification of <b>none</b> causes |
| 264 |
nothing to happen in the widget command. |
| 265 |
This form may not be abbreviated. |
| 266 |
</p></dd> |
| 267 |
<dt><b>@</b><i>number</i></dt> |
| 268 |
<dd><p>In this form, <i>number</i> is treated as a y-coordinate in the |
| 269 |
menu’s window; the entry spanning that y-coordinate is used. |
| 270 |
For example, “<b>@0</b>” indicates the top-most entry in the |
| 271 |
window. If <i>number</i> is outside the range of the window |
| 272 |
then this form is equivalent to <b>none</b>. |
| 273 |
</p></dd> |
| 274 |
<dt><i>pattern</i></dt> |
| 275 |
<dd><p>If the index doesn’t satisfy one of the above forms then this |
| 276 |
form is used. <i>Pattern</i> is pattern-matched against the label of |
| 277 |
each entry in the menu, in order from the top down, until a |
| 278 |
matching entry is found. The rules of <b>Tcl_StringMatch</b> |
| 279 |
are used. |
| 280 |
</p> |
| 281 |
<p>The following widget commands are possible for menu widgets: |
| 282 |
</p></dd> |
| 283 |
<dt><i>pathName </i><b>:activate </b><i>index</i></dt> |
| 284 |
<dd><p>Change the state of the entry indicated by <i>index</i><span class="roman"> to </span><b>active</b> |
| 285 |
and redisplay it using its active colors. |
| 286 |
Any previously-active entry is deactivated. If <i>index</i> |
| 287 |
is specified as <b>none</b>, or if the specified entry is |
| 288 |
disabled, then the menu ends up with no active entry. |
| 289 |
Returns an empty string. |
| 290 |
</p></dd> |
| 291 |
<dt><i>pathName </i><b>:add </b><i>type </i><span class="roman">?</span><i>option value option value ...</i>?</dt> |
| 292 |
<dd><p>Add a new entry to the bottom of the menu. The new entry’s type |
| 293 |
is given by <i>type</i><span class="roman"> and must be one of </span><b>cascade</b>, |
| 294 |
<b>checkbutton</b><span class="roman">, </span><b>command</b><span class="roman">, </span><b>radiobutton</b><span class="roman">, or </span><b>separator</b>, |
| 295 |
or a unique abbreviation of one of the above. If additional arguments |
| 296 |
are present, they specify any of the following options: |
| 297 |
</p> |
| 298 |
<dl compact="compact"> |
| 299 |
<dt><b>:activebackground </b><i>value</i></dt> |
| 300 |
<dd><p>Specifies a background color to use for displaying this entry when it |
| 301 |
is active. |
| 302 |
If this option is specified as an empty string (the default), then the |
| 303 |
<b>activeBackground</b> option for the overall menu is used. |
| 304 |
This option is not available for separator entries. |
| 305 |
</p></dd> |
| 306 |
<dt><b>:accelerator </b><i>value</i></dt> |
| 307 |
<dd><p>Specifies a string to display at the right side of the menu entry. |
| 308 |
Normally describes an accelerator keystroke sequence that may be |
| 309 |
typed to invoke the same function as the menu entry. This option |
| 310 |
is not available for separator entries. |
| 311 |
</p></dd> |
| 312 |
<dt><b>:background </b><i>value</i></dt> |
| 313 |
<dd><p>Specifies a background color to use for displaying this entry when it |
| 314 |
is in the normal state (neither active nor disabled). |
| 315 |
If this option is specified as an empty string (the default), then the |
| 316 |
<b>background</b> option for the overall menu is used. |
| 317 |
This option is not available for separator entries. |
| 318 |
</p></dd> |
| 319 |
<dt><b>:bitmap </b><i>value</i></dt> |
| 320 |
<dd><p>Specifies a bitmap to display in the menu instead of a textual |
| 321 |
label, in any of the forms accepted by <b>Tk_GetBitmap</b>. |
| 322 |
This option overrides the <b>:label</b> option but may be reset |
| 323 |
to an empty string to enable a textual label to be displayed. |
| 324 |
This option is not available for separator entries. |
| 325 |
</p></dd> |
| 326 |
<dt><b>:command </b><i>value</i></dt> |
| 327 |
<dd><p>For command, checkbutton, and radiobutton entries, specifies a |
| 328 |
Tcl command to execute when the menu entry is invoked. |
| 329 |
For cascade entries, specifies a Tcl command to execute |
| 330 |
when the entry is activated (i.e. just before its submenu is |
| 331 |
posted). |
| 332 |
Not available for separator entries. |
| 333 |
</p></dd> |
| 334 |
<dt><b>:font </b><i>value</i></dt> |
| 335 |
<dd><p>Specifies the font to use when drawing the label or accelerator |
| 336 |
string in this entry. |
| 337 |
If this option is specified as an empty string (the default) then |
| 338 |
the <b>font</b> option for the overall menu is used. |
| 339 |
This option is not available for separator entries. |
| 340 |
</p></dd> |
| 341 |
<dt><b>:label </b><i>value</i></dt> |
| 342 |
<dd><p>Specifies a string to display as an identifying label in the menu |
| 343 |
entry. Not available for separator entries. |
| 344 |
</p></dd> |
| 345 |
<dt><b>:menu </b><i>value</i></dt> |
| 346 |
<dd><p>Available only for cascade entries. Specifies the path name of |
| 347 |
the menu associated with this entry. |
| 348 |
</p></dd> |
| 349 |
<dt><b>:offvalue </b><i>value</i></dt> |
| 350 |
<dd><p>Available only for check-button entries. Specifies the value to |
| 351 |
store in the entry’s associated variable when the entry is |
| 352 |
deselected. |
| 353 |
</p></dd> |
| 354 |
<dt><b>:onvalue </b><i>value</i></dt> |
| 355 |
<dd><p>Available only for check-button entries. Specifies the value to |
| 356 |
store in the entry’s associated variable when the entry is selected. |
| 357 |
</p></dd> |
| 358 |
<dt><b>:state </b><i>value</i></dt> |
| 359 |
<dd><p>Specifies one of three states for the entry: <b>normal</b><span class="roman">, </span><b>active</b>, |
| 360 |
or <b>disabled</b>. In normal state the entry is displayed using the |
| 361 |
<b>foreground</b><span class="roman"> option for the menu and the </span><b>background</b> |
| 362 |
option from the entry or the menu. |
| 363 |
The active state is typically used when the pointer is over the entry. |
| 364 |
In active state the entry is displayed using the <b>activeForeground</b> |
| 365 |
option for the menu along with the <b>activebackground</b> option from |
| 366 |
the entry. |
| 367 |
Disabled state means that the entry is insensitive: it doesn’t activate |
| 368 |
and doesn’t respond to mouse button presses or releases. |
| 369 |
In this state the entry is displayed according to the |
| 370 |
<b>disabledForeground</b> option for the menu and the |
| 371 |
<b>background</b> option from the entry. |
| 372 |
This option is not available for separator entries. |
| 373 |
</p></dd> |
| 374 |
<dt><b>:underline </b><i>value</i></dt> |
| 375 |
<dd><p>Specifies the integer index of a character to underline in the entry. |
| 376 |
This option is typically used to indicate keyboard traversal characters. |
| 377 |
0 corresponds to the first character of the text displayed in the entry, |
| 378 |
1 to the next character, and so on. |
| 379 |
If a bitmap is displayed in the entry then this option is ignored. |
| 380 |
This option is not available for separator entries. |
| 381 |
</p></dd> |
| 382 |
<dt><b>:value </b><i>value</i></dt> |
| 383 |
<dd><p>Available only for radio-button entries. Specifies the value to |
| 384 |
store in the entry’s associated variable when the entry is selected. |
| 385 |
</p></dd> |
| 386 |
<dt><b>:variable </b><i>value</i></dt> |
| 387 |
<dd><p>Available only for check-button and radio-button entries. Specifies |
| 388 |
the name of a global value to set when the entry is selected. |
| 389 |
For check-button entries the variable is also set when the entry |
| 390 |
is deselected. For radio-button entries, changing the variable |
| 391 |
causes the currently-selected entry to deselect itself. |
| 392 |
</p></dd> |
| 393 |
</dl> |
| 394 |
</dd> |
| 395 |
</dl> |
| 396 |
|
| 397 |
<p>The <b>add</b> widget command returns an empty string. |
| 398 |
</p> |
| 399 |
|
| 400 |
<dl compact="compact"> |
| 401 |
<dt><i>pathName </i><b>:configure</b><span class="roman"> ?</span><i>option</i><span class="roman">? ?</span><i>value option value ...</i>?</dt> |
| 402 |
<dd><p>Query or modify the configuration options of the widget. |
| 403 |
If no <i>option</i> is specified, returns a list describing all of |
| 404 |
the available options for <i>pathName</i><span class="roman"> (see </span><b>Tk_ConfigureInfo</b> for |
| 405 |
information on the format of this list). If <i>option</i> is specified |
| 406 |
with no <i>value</i>, then the command returns a list describing the |
| 407 |
one named option (this list will be identical to the corresponding |
| 408 |
sublist of the value returned if no <i>option</i> is specified). If |
| 409 |
one or more <i>option:value</i> pairs are specified, then the command |
| 410 |
modifies the given widget option(s) to have the given value(s); in |
| 411 |
this case the command returns an empty string. |
| 412 |
<i>Option</i><span class="roman"> may have any of the values accepted by the </span><b>menu</b> |
| 413 |
command. |
| 414 |
</p></dd> |
| 415 |
<dt><i>pathName </i><b>:delete </b><i>index1</i><span class="roman"> ?</span><i>index2</i>?</dt> |
| 416 |
<dd><p>Delete all of the menu entries between <i>index1</i> and |
| 417 |
<i>index2</i> inclusive. |
| 418 |
If <i>index2</i><span class="roman"> is omitted then it defaults to </span><i>index1</i>. |
| 419 |
Returns an empty string. |
| 420 |
</p></dd> |
| 421 |
<dt><i>pathName </i><b>:disable </b><i>index</i></dt> |
| 422 |
<dd><p>Change the state of the entry given by <i>index</i><span class="roman"> to </span><b>disabled</b> |
| 423 |
and redisplay the entry using its disabled colors. |
| 424 |
Returns an empty string. |
| 425 |
This command is obsolete and will eventually be removed; |
| 426 |
use “<i>pathName </i><b>:entryconfigure </b><i>index</i><span class="roman"> :state disabled</span>” instead. |
| 427 |
</p></dd> |
| 428 |
<dt><i>pathName </i><b>:enable </b><i>index</i></dt> |
| 429 |
<dd><p>Change the state of the entry given by <i>index</i><span class="roman"> to </span><b>normal</b> |
| 430 |
and redisplay the entry using its normal colors. |
| 431 |
Returns an empty string. |
| 432 |
This command is obsolete and will eventually be removed; |
| 433 |
use “<i>pathName </i><b>:entryconfigure </b><i>index</i><span class="roman"> :state normal</span>” instead. |
| 434 |
</p></dd> |
| 435 |
<dt><i>pathName </i><b>:entryconfigure </b><i>index</i><span class="roman"> </span><span class="roman">?</span><i>options</i>?</dt> |
| 436 |
<dd><p>This command is similar to the <b>configure</b> command, except that |
| 437 |
it applies to the options for an individual entry, whereas <b>configure</b> |
| 438 |
applies to the options for the menu as a whole. |
| 439 |
<i>Options</i><span class="roman"> may have any of the values accepted by the </span><b>add</b> |
| 440 |
widget command. If <i>options</i> are specified, options are modified |
| 441 |
as indicated |
| 442 |
in the command and the command returns an empty string. |
| 443 |
If no <i>options</i> are specified, returns a list describing |
| 444 |
the current options for entry <i>index</i><span class="roman"> (see </span><b>Tk_ConfigureInfo</b> for |
| 445 |
information on the format of this list). |
| 446 |
</p></dd> |
| 447 |
<dt><i>pathName </i><b>:index </b><i>index</i></dt> |
| 448 |
<dd><p>Returns the numerical index corresponding to <i>index</i>, or |
| 449 |
<b>none</b><span class="roman"> if </span><i>index</i><span class="roman"> was specified as </span><b>none</b>. |
| 450 |
</p></dd> |
| 451 |
<dt><i>pathName </i><b>:invoke </b><i>index</i></dt> |
| 452 |
<dd><p>Invoke the action of the menu entry. See the sections on the |
| 453 |
individual entries above for details on what happens. If the |
| 454 |
menu entry is disabled then nothing happens. If the |
| 455 |
entry has a command associated with it then the result of that |
| 456 |
command is returned as the result of the <b>invoke</b> widget |
| 457 |
command. Otherwise the result is an empty string. Note: invoking |
| 458 |
a menu entry does not automatically unpost the menu. Normally |
| 459 |
the associated menubutton will take care of unposting the menu. |
| 460 |
</p></dd> |
| 461 |
<dt><i>pathName </i><b>:post </b><i>x y</i></dt> |
| 462 |
<dd><p>Arrange for the menu to be displayed on the screen at the root-window |
| 463 |
coordinates given by <i>x</i><span class="roman"> and </span><i>y</i>. These coordinates are |
| 464 |
adjusted if necessary to guarantee that the entire menu is visible on |
| 465 |
the screen. This command normally returns an empty string. |
| 466 |
If the <b>:postcommand</b> option has been specified, then its value is |
| 467 |
executed as a Tcl script before posting the menu and the result of |
| 468 |
that script is returned as the result of the <b>post</b> widget |
| 469 |
command. |
| 470 |
If an error returns while executing the command, then the error is |
| 471 |
returned without posting the menu. |
| 472 |
</p></dd> |
| 473 |
<dt><i>pathName </i><b>:unpost</b></dt> |
| 474 |
<dd><p>Unmap the window so that it is no longer displayed. If a |
| 475 |
lower-level cascaded menu is posted, unpost that menu. Returns an |
| 476 |
empty string. |
| 477 |
</p></dd> |
| 478 |
<dt><i>pathName </i><b>:yposition </b><i>index</i></dt> |
| 479 |
<dd><p>Returns a decimal string giving the y-coordinate within the menu |
| 480 |
window of the topmost pixel in the entry specified by <i>index</i>. |
| 481 |
</p> |
| 482 |
|
| 483 |
</dd> |
| 484 |
</dl> |
| 485 |
<span id="Default-Bindings"></span><h4 class="unnumberedsubsec">Default Bindings</h4> |
| 486 |
|
| 487 |
|
| 488 |
<p>Tk automatically creates class bindings for menus that give them |
| 489 |
the following default behavior: |
| 490 |
</p><ul class="no-bullet"> |
| 491 |
<li> [1] |
| 492 |
When the mouse cursor enters a menu, the entry underneath the mouse |
| 493 |
cursor is activated; as the mouse moves around the menu, the active |
| 494 |
entry changes to track the mouse. |
| 495 |
</li><li> [2] |
| 496 |
When button 1 is released over a menu, the active entry (if any) is invoked. |
| 497 |
</li><li> [3] |
| 498 |
A menu can be repositioned on the screen by dragging it with mouse |
| 499 |
button 2. |
| 500 |
</li><li> [4] |
| 501 |
A number of other bindings are created to support keyboard menu traversal. |
| 502 |
See the manual entry for <b>tk_bindForTraversal</b> for details on these |
| 503 |
bindings. |
| 504 |
</li></ul> |
| 505 |
|
| 506 |
<p>Disabled menu entries are non-responsive: they don’t activate and |
| 507 |
ignore mouse button presses and releases. |
| 508 |
</p> |
| 509 |
<p>The behavior of menus can be changed by defining new bindings for |
| 510 |
individual widgets or by redefining the class bindings. |
| 511 |
</p> |
| 512 |
<span id="Bugs"></span><h4 class="unnumberedsubsec">Bugs</h4> |
| 513 |
|
| 514 |
<p>At present it isn’t possible to use the |
| 515 |
option database to specify values for the options to individual |
| 516 |
entries. |
| 517 |
</p> |
| 518 |
<span id="Keywords-4"></span><h4 class="unnumberedsubsec">Keywords</h4> |
| 519 |
<p>menu, widget |
| 520 |
</p><hr> |
| 521 |
<div class="header"> |
| 522 |
<p> |
| 523 |
Next: <a href="scrollbar.html" accesskey="n" rel="next">scrollbar</a>, Previous: <a href="canvas.html" accesskey="p" rel="prev">canvas</a>, Up: <a href="Widgets.html" accesskey="u" rel="up">Widgets</a> [<a href="wm.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> |
| 524 |
</div> |
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
</body> |
| 529 |
</html> |