1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
|
<HTML>
<HEAD>
<TITLE>iwidgets2.2.0 User Commands - menubar</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1>iwidgets2.2.0 User Commands - menubar</H1>
<HR>
<PRE>
</PRE>
<H2><HR ALIGN=LEFT WIDTH=70% SIZE=3></H2><PRE>
</PRE>
<H2>NAME</H2><PRE>
menubar - Create and manipulate menubar menu widgets
</PRE>
<H2>SYNOPSIS</H2><PRE>
<STRONG>menubar</STRONG> <EM>pathName</EM> ?<EM>options</EM>?
</PRE>
<H2>INHERITANCE</H2><PRE>
itk::Widget <- menubar
</PRE>
<H2>STANDARD OPTIONS</H2><PRE>
<STRONG>activeBackground</STRONG> <STRONG>borderWidth</STRONG> <STRONG>highlightBackgroundpadY</STRONG>
<STRONG>activeBorderWidth</STRONG> <STRONG>cursor</STRONG> <STRONG>highligthThicknessrelief</STRONG>
<STRONG>activeForeground</STRONG> <STRONG>disabledForegroundhighlightColorwrapLength</STRONG>
<STRONG>anchor</STRONG> <STRONG>font</STRONG> <STRONG>justify</STRONG>
<STRONG>background</STRONG> <STRONG>foreground</STRONG> <STRONG>padX</STRONG>
See the "options" manual entry for details on the standard
options.
</PRE>
<H2>WIDGET-SPECIFIC OPTIONS</H2><PRE>
Name: <STRONG>helpVariable</STRONG>
Class: <STRONG>HelpVariable</STRONG>
Command-Line Switch: <STRONG>-helpvariable</STRONG>
Specifies the global variable to update whenever the
mouse is in motion over a menu entry. This global vari-
able is updated with the current value of the active
menu entry's <STRONG>helpStr</STRONG>. Other widgets can "watch" this
variable with the trace command, or as is the case with
entry or label widgets, they can set their <STRONG>textVariable</STRONG>
to the same global variable. This allows for a simple
implementation of a help status bar. Whenever the mouse
leaves a menu entry, the helpVariable is set to the
empty string {}. The mainwindow(1) associates its
helpstatus and its menubar in this fashion.
Name: <STRONG>menuButtons</STRONG>
Class: <STRONG>MenuButtons</STRONG>
Command-Line Switch: <STRONG>-menubuttons</STRONG>
The menuButton option is a string which specifies the
arrangement of menubuttons on the menubar frame. Each
menubutton entry is delimited by the newline character.
menubar .mb -menubuttons {
menubutton file -text File
menubutton edit -text Edit
menubutton options -text Options
}
specifies that three menubuttons will be added to the
menubar (file, edit, options). Each entry is translated
into an add command call.
The <STRONG>menuButtons</STRONG> option can accept embedded variables,
commands, and backslash quoting. Embedded variables and
commands must be enclosed in curly braces ({}) to
ensure proper parsing of the substituted values.
</PRE>
<H2><HR ALIGN=LEFT WIDTH=70% SIZE=3></H2><PRE>
</PRE>
<H2>DESCRIPTION</H2><PRE>
The <STRONG>menubar</STRONG> command creates a new window (given by the <EM>path-</EM>
<EM>Name</EM> argument) and makes it into a <STRONG>menubar</STRONG> menu widget.
Additional options, described above may be specified on the
command line or in the option database to configure aspects
of the menubar such as its colors and font. The <STRONG>menubar</STRONG> com-
mand returns its <EM>pathName</EM> argument. At the time this command
is invoked, there must not exist a window named pathName,
but pathName's parent must exist.
A <STRONG>menubar</STRONG> is a widget that simplifies the task of creating
menu hierarchies. It encapsulates a <STRONG>frame</STRONG> widget, as well as
<STRONG>menubuttons</STRONG>, <STRONG>menus</STRONG>, and menu <STRONG>entries</STRONG>. The menubar allows
menus to be specified and referenced in a more consistent
manner than using Tk to build menus directly.
<STRONG>Menubar</STRONG> allows a menu tree to be expressed in a hierachical
"language". The <STRONG>menubar</STRONG> accepts a <STRONG>menuButtons</STRONG> option that
allows a list of menubuttons to be added to the menubar. In
turn, each menubutton accepts a <STRONG>menu</STRONG> option that specifies a
list of menu entries to be added to the menubutton's menu.
Cascade entries also accept the <STRONG>menu</STRONG> option for specifying a
list of menu entries to be added to the cascade's menu.
Additionally, the menubar allows each component of the menu-
bar system to be referenced by a simple <EM>menuPathName</EM> syntax.
The menubar also extends the set of options for menu entries
to include a <STRONG>helpStr</STRONG> option.
</PRE>
<H2>MENU PATH NAMES</H2><PRE>
A <EM>menuPathName</EM> is a series of component names separated by
the `.' character. Each menubar component can be referenced
via these <EM>menuPathNames</EM>. <EM>menuPathNames</EM> are similar to widget
pathNames in Tk. Some correspond directly to a widget path-
Name (components of type <STRONG>menu</STRONG> or <STRONG>menubutton</STRONG>), others
correspond to a menu entry type. Every widget and entry in a
menubar can be referenced with the <EM>menuPathName</EM> naming con-
vention. A menubar can have four types of components:
<STRONG>frame</STRONG>. A menubar holds exactly one frame which manages
menubuttons. The frame is always signified by the `.'
character as the path name.
<STRONG>menubutton</STRONG>. A menubutton corresponds directly to a Tk
menubutton. See menubutton(n).
<STRONG>menu</STRONG>. A menu is attached to a menubutton and
corresponds directly to Tk's menu widget. A menu is
always signified by the <EM>menuPathName</EM> ending with the
keyword <STRONG>menu</STRONG>. See menu(n).
<STRONG>entry</STRONG>. An entry corresponds directly to Tk's menu
widget entries. Menus consist of a column of one line
entries. Entries may be of type: <STRONG>command</STRONG>, <STRONG>checkbutton</STRONG>,
<STRONG>radiobutton</STRONG>, <STRONG>separator</STRONG>, or <STRONG>cascade</STRONG>. For a complete
description of these types see the discussion on
<STRONG>ENTRIES</STRONG> in menu(n).
The suffix of a <EM>menuPathName</EM> may have the form of:
<EM>tkWidgetName</EM> Specifies the name of the component, either a
<STRONG>frame</STRONG>, <STRONG>menubutton</STRONG>, <STRONG>menu</STRONG>, or an <STRONG>entry</STRONG>. This is
the normal naming of widgets. For example,
.file references a <STRONG>menubutton</STRONG> named <EM>file</EM>.
The <EM>menuPathName</EM> is a series of segment names, each
separated by the '.' character. Segment names may be one of
the following forms:
<EM>number</EM> Specifies the index of the the component. For
menubuttons, 0 corresponds to the left-most
menubutton of the menu bar frame. As an exam-
ple, .<EM>1</EM> would correspond to the second menu-
button on the menu bar frame.
For entries, 0 corresponds to the top-most
entry of the menu. For example, .file.0 would
correspond to the first entry on the menu
attached to the menubutton named <EM>file</EM>.
<STRONG>end</STRONG> Specifes the last component. For menubuttons,
it specifies the right-most entry of the menu
bar frame. For menu entries, it specifies the
bottom-most entry of the menu.
<STRONG>last</STRONG> Same as end.
Finally, menu components always end with the <STRONG>menu</STRONG> keyword.
These components are automatically created via the -menu
option on menubuttons and cascades or via the <STRONG>add</STRONG> or <STRONG>insert</STRONG>
commands.
<STRONG>menu</STRONG> Specifes the menu pane that is associated with
the given menubutton prefix. For example,
.<EM>file</EM>.<EM>menu</EM> specifies the menu pane attached to
the
For example, the path .<EM>file</EM>.<EM>new</EM> specifies the entry named
new on the menu associated with the file menubutton located
on the menu bar. The path .<EM>file</EM>.<EM>menu</EM> specifies the menu pane
associated with the menubutton .<EM>file</EM>. The path .<EM>last</EM> speci-
fies the last menu on the menu bar. The path .<EM>0</EM>.<EM>last</EM> would
specify the first menu (file) and the last entry on that
menu (quit), yielding .<EM>file</EM>.<EM>quit</EM>.
As a restriction, the last name segment of <EM>menuPathName</EM> can-
not be one of the keywords last, menu, end, nor may it be a
numeric value (integer).
</PRE>
<H2>WIDGET-SPECIFIC METHODS</H2><PRE>
The <STRONG>menubar</STRONG> command creates a new Tcl command whose name is
<EM>pathName</EM>. This command may be used to invoke various opera-
tions on the widget. It has the following general form:
<EM>pathName</EM> <EM>option</EM> ?<EM>arg</EM> <EM>arg</EM> ...?
<EM>option</EM> and the <EM>arg</EM>s determine the exact behavior of the com-
mand.
In addition, many of the widget commands for menubar take as
one argument a path name to a menu component. These path
names are called <EM>menuPathName</EM>s. See the discussion on <STRONG>MENU-</STRONG>
<STRONG>BAR</STRONG> <STRONG>PATH</STRONG> <STRONG>NAMES</STRONG> above.
The following commands are possible for menubar widgets:
<EM>pathName</EM> <STRONG>add</STRONG> <EM>type</EM> <EM>menuPathName</EM> ?<EM>option</EM> <EM>value</EM> <EM>option</EM> <EM>value</EM>?
Adds either a menu to the menu bar or a menu entry to a
menu pane.
If additional arguments are present, they specify
<EM>option</EM>s available to component type <STRONG>entry</STRONG>. See the man
pages for <STRONG>menu</STRONG>(1) in the section on <STRONG>ENTRIES</STRONG>.
If <EM>type</EM> is one of <STRONG>cascade</STRONG>, <STRONG>checkbutton</STRONG>, <STRONG>command</STRONG>,
<STRONG>radiobutton</STRONG>, or <STRONG>separator</STRONG> it adds a new entry to the
bottom of the menu denoted by the prefix of <EM>menuPath-</EM>
<EM>Name</EM>. If additonal arguments are present, they specify
options available to menu <STRONG>entry</STRONG> widgets. In addition,
the <STRONG>helpStr</STRONG> option is added by the menubar widget to
all components of type entry.
<STRONG>-helpstr</STRONG> <EM>value</EM>
Specifes the string to associate with the entry.
When the mouse moves over the associated entry,
the variable denoted by <STRONG>helpVariable</STRONG> is set.
Another widget can bind to the helpVariable and
thus display status help.
If the type of the component added is <STRONG>menubutton</STRONG> or
<STRONG>cascade</STRONG>, a menubutton or cascade is added to the menu-
bar. If additional arguments are present, they specify
options available to menubutton or cascade widgets. In
addition, the <STRONG>menu</STRONG> option is added by the menubar
widget to all menubutton and cascade widgets.
<STRONG>-menu</STRONG> <EM>menuSpec</EM>
This is only valid for <EM>menuPathName</EM>s of type <STRONG>menu-</STRONG>
<STRONG>button</STRONG> or <STRONG>cascade</STRONG>. Specifes an option set and/or a
set of entries to place on a menu and associate
with the menubutton or cascade. The <STRONG>option</STRONG> keyword
allows the menu widget to be configured. Each item
in the <EM>menuSpec</EM> is treated as add commands (each
with the possibility of having other -menu
options). In this way a menu can be recursively
built.
The last segment of <EM>menuPathName</EM> cannot be one of
the keywords <STRONG>last</STRONG>, <STRONG>menu</STRONG>, <STRONG>end</STRONG>. Additionally, it may
not be a <EM>number</EM>. However the <EM>menuPathName</EM> may be
referenced in this manner (see discussion of <STRONG>COM-</STRONG>
<STRONG>PONENT</STRONG> <STRONG>PATH</STRONG> <STRONG>NAMES</STRONG>).
Note that the same curly brace quoting rules apply
to <STRONG>-menu</STRONG> option strings as did to <STRONG>-menubuttons</STRONG>
option strings. See the earlier discussion on
<STRONG>umenubuttons</STRONG> in the "<STRONG>WIDGET-SPECIFIC</STRONG> <STRONG>OPTIONS</STRONG>" sec-
tion.
<EM>pathName</EM> <STRONG>cget</STRONG> <EM>option</EM>
Returns the current value of the configuration option
given by <EM>option</EM>.
<EM>pathName</EM> <STRONG>configure</STRONG> ?<EM>options</EM> <EM>value</EM> <EM>option</EM> <EM>value</EM>?
Query or modify the configuration options of the
widget. If no <EM>option</EM> is specified, returns a list
describing all of the available options for <STRONG>pathName</STRONG>
(see <STRONG>Tk_ConfigureInfo</STRONG> for information on the format of
this list). If <EM>option</EM> is specified with no value, then
the command returns a list describing the one named
option (this list will be identical to the correspond-
ing sublist of the value returned if no option is
specified). If one or more option-value pairs are
specified, then the command modifies the given widget
option(s) to have the given value(s); in this case the
command returns an empty string.
<EM>pathName</EM> <STRONG>delete</STRONG> <EM>menuPathName</EM> ?<EM>menuPathName2</EM>?
If <EM>menuPathName</EM> is of component type <STRONG>Menubutton</STRONG> or
<STRONG>Menu</STRONG>, delete operates on menus. If <EM>menuPathName</EM> is of
component type <STRONG>Entry</STRONG>, delete operates on menu entries.
This command deletes all components between <EM>menuPath-</EM>
<EM>Name</EM> and <EM>menuPathName2</EM> inclusive. If <EM>menuPathName2</EM> is
omitted then it defaults to <EM>menuPathName</EM>. Returns an
empty string.
If <EM>menuPathName</EM> is of type menubar, then all menus and
the menu bar frame will be destroyed. In this case
<EM>menuPathName2</EM> is ignored.
<EM>pathName</EM> <STRONG>index</STRONG> <EM>menuPathName</EM>
If <EM>menuPathName</EM> is of type menubutton or menu, it
returns the position of the menu/menubutton on the
menubar frame.
If <EM>menuPathName</EM> is of type <STRONG>command</STRONG>, <STRONG>separator</STRONG>,
<STRONG>radiobutton</STRONG>, <STRONG>checkbutton</STRONG>, or <STRONG>cascade</STRONG>, it returns the
menu widget's numerical index for the entry correspond-
ing to <EM>menuPathName</EM>. If path is not found or the path
is equal to ".", a value of -1 is returned.
<EM>pathName</EM> <STRONG>insert</STRONG> <EM>menuPathName</EM> <EM>type</EM> <EM>name</EM> ?<EM>option</EM> <EM>value</EM>?
Insert a new component named name before the component
specified by <EM>menuPathName</EM>.
If <EM>menuPathName</EM> is of type <STRONG>Menubutton</STRONG> or <STRONG>Menu</STRONG>, the new
component inserted is of type <STRONG>Menu</STRONG> and given the name
name. In this case valid <EM>option</EM> <EM>value</EM> pairs are those
accepted by menubuttons.
If <EM>menuPathName</EM> is of type <STRONG>Entry</STRONG>, the new component
inserted is of type <STRONG>entry</STRONG> and given the name <EM>name</EM>. In
this case, valid <EM>option</EM> <EM>value</EM> pairs are those accepted
by menu entries. <EM>Name</EM> cannot be one of the keywords
<STRONG>last</STRONG>, <STRONG>menu</STRONG>, <STRONG>end</STRONG>. Additionally, it may not be a number.
However the <EM>menuPathName</EM> may be referenced in this
manner (see discussion of <STRONG>COMPONENT</STRONG> <STRONG>PATH</STRONG> <STRONG>NAMES</STRONG>).
<EM>pathName</EM> <STRONG>invoke</STRONG> <EM>menuPathName</EM>
Invoke the action of the menu entry denoted by <EM>menu-</EM>
<EM>PathName</EM>. See the sections on the individual entries in
the menu(1) man pages. If the menu entry is disabled
then nothing happens. If the entry has a command asso-
ciated with it then the result of that command is
returned as the result of the <STRONG>invoke</STRONG> widget command.
Otherwise the result is an empty string.
If <EM>menuPathName</EM> is not a menu entry, an error is
issued.
<EM>pathName</EM> <STRONG>menucget</STRONG> <EM>menuPathName</EM> ?<EM>option</EM> <EM>value</EM> <EM>option</EM> <EM>value</EM>?
Returns the current value of the configuration option
given by <EM>option</EM>. The component type of <EM>menuPathName</EM>
determines the valid available options.
<EM>pathName</EM> <STRONG>menuconfigure</STRONG> <EM>menuPathName</EM> ?<EM>option</EM> <EM>value</EM>?
Query or modify the configuration options of the com-
ponet of the menubar specified by <EM>menuPathName</EM>. If no
<EM>option</EM> is specified, returns a list describing all of
the available options for <EM>menuPathName</EM> (see
<STRONG>Tk_ConfigureInfo</STRONG> for information on the format of this
list). If <EM>option</EM> is specified with no value, then the
command returns a list describing the one named option
(this list will be identical to the corresponding sub-
list of the value returned if no option is specified).
If one or more option-value pairs are specified, then
the command modifies the given widget option(s) to have
the given value(s); in this case the command returns an
empty string. The component type of <EM>menuPathName</EM> deter-
mines the valid available options.
<EM>pathName</EM> <STRONG>path</STRONG> ?<EM>mode</EM>? <EM>pattern</EM>
Returns a fully formed <EM>menuPathName</EM> that matches <EM>pat-</EM>
<EM>tern</EM>. If no match is found it returns -1. The <EM>mode</EM>
argument indicates how the search is to be matched
against <EM>pattern</EM> and it must have one of the following
values:
<STRONG>-glob</STRONG>
Pattern is a glob-style pattern which is matched
against each component path using the same rules
as the string match command.
<STRONG>-regexp</STRONG>
Pattern is treated as a regular expression and
matched against each component of the <EM>menuPathName</EM>
using the same rules as the regexp command. The
default mode is -glob.
<EM>pathName</EM> <STRONG>type</STRONG> <EM>menuPathName</EM>
Returns the type of the component specified by <EM>menu-</EM>
<EM>PathName</EM>. For menu entries, this is the type argument
passed to the <STRONG>add</STRONG>/<STRONG>insert</STRONG> widget command when the entry
was created, such as <STRONG>command</STRONG> or <STRONG>separator</STRONG>. Othewise it
is either a <STRONG>menubutton</STRONG> or a <STRONG>menu</STRONG>.
<EM>pathName</EM> <STRONG>yposition</STRONG> <EM>menuPathName</EM>
Returns a decimal string giving the y-coordinate within
the menu window of the topmost pixel in the entry
specified by <EM>menuPathName</EM>. If the <EM>menuPathName</EM> is not
an entry, an error is issued.
</PRE>
<H2>EXAMPLE ONE: USING GRAMMAR</H2><PRE>
The following example creates a menubar with "File", "Edit",
"Options" menubuttons. Each of these menubuttons has an
associated menu. In turn the File menu has menu entries, as
well as the Edit menu and the Options menu. The Options menu
is a tearoff menu with selectColor (for radiobuttons) set to
blue. In addition, the Options menu has a cascade titled
More, with several menu entries attached to it as well. An
entry widget is provided to display help status.
menubar .mb -helpvariable helpVar -menubuttons {
menubutton file -text File -menu {
options -tearoff false
command new -label New \
-helpstr "Open new document" \
-command {puts NEW}
command close -label Close \
-helpstr "Close current document" \
-command {puts CLOSE}
separator sep1
command exit -label Exit -command {exit} \
-helpstr "Exit application"
}
menubutton edit -text Edit -menu {
options -tearoff false
command undo -label Undo -underline 0 \
-helpstr "Undo last command" \
-command {puts UNDO}
separator sep2
command cut -label Cut -underline 1 \
-helpstr "Cut selection to clipboard" \
-command {puts CUT}
command copy -label Copy -underline 1 \
-helpstr "Copy selection to clipboard" \
-command {puts COPY}
command paste -label Paste -underline 0 \
-helpstr "Paste clipboard contents" \
-command {puts PASTE}
}
menubutton options -text Options -menu {
options -tearoff false -selectcolor blue
radiobutton byName -variable viewMode \
-value NAME -label "by Name" \
-helpstr "View files by name order" \
-command {puts NAME}
radiobutton byDate -variable viewMode \
-value DATE -label "by Date" \
-helpstr "View files by date order" \
-command {puts DATE}
cascade prefs -label Preferences -menu {
command colors -label Colors... \
-helpstr "Change text colors" \
-command {puts COLORS}
command fonts -label Fonts... \
-helpstr "Change text font" \
-command {puts FONT}
}
}
}
frame .fr -width 300 -height 300
entry .ef -textvariable helpVar
pack .mb -anchor nw -fill x -expand yes
pack .fr -fill both -expand yes
pack .ef -anchor sw -fill x -expand yes
</PRE>
<H2>EXAMPLE TWO: USING METHODS</H2><PRE>
Alternatively the same menu could be created by using the
add and configure methods:
menubar .mb
.mb configure -menubuttons {
menubutton file -text File -menu {
command new -label New
command close -label Close
separator sep1
command quit -label Quit
}
menubutton edit -text Edit
}
.mb add command .edit.undo -label Undo -underline 0
.mb add separator .edit.sep2
.mb add command .edit.cut -label Cut -underline 1
.mb add command .edit.copy -label Copy -underline 1
.mb add command .edit.paste -label Paste -underline 0
.mb add menubutton .options -text Options -menu {
radiobutton byName -variable viewMode \
-value NAME -label "by Name"
radiobutton byDate -variable viewMode \
-value DATE -label "by Date"
}
.mb add cascade .options.prefs -label Preferences -menu {
command colors -label Colors...
command fonts -label Fonts...
}
pack .mb -side left -anchor nw -fill x -expand yes
</PRE>
<H2>CAVEATS</H2><PRE>
The <STRONG>-menubuttons</STRONG> option as well as the <STRONG>-menu</STRONG> option is
evaluated by menubar with the <STRONG>subst</STRONG> command. The positive
side of this is that the option string may contain vari-
ables, commands, and/or backslash substitutions. However,
substitutions might expand into more than a single word.
These expansions can be protected by enclosing candidate
substitutions in curly braces ({}). This ensures, for exam-
ple, a value for an option will still be treated as a single
value and not multiple values. The following example illus-
trates this case:
set fileMenuName "File Menu"
set var {}
menubar .mb -menubuttons {
menubutton file -text {$fileMenuName}
menubutton edit -text Edit -menu {
checkbutton check \
-label Check \
-variable {[scope var]} \
-onvalue 1 \
-offvalue 0
}
menubutton options -text Options
}
The variable <EM>fileMenuName</EM> will expand to "File Menu"
when the <STRONG>subst</STRONG> command is used on the menubutton
specification. In addition, the [<STRONG>scope</STRONG>...] command will
expand to @scope :: var. By enclosing these inside {}
they stay as a single value. Note that only {} work for
this. [list...], "" etc. will not protect these from
the subst command.
</PRE>
<H2>ACKNOWLEDGMENTS</H2><PRE>
Bret Schumaker
1994 - Early work on a menubar widget.
Mark Ulferts, Mark Harrison, John Sigler
Invaluable feedback on grammar and usability of the
menubar widget
</PRE>
<H2>AUTHOR</H2><PRE>
Bill W. Scott
</PRE>
<H2>KEYWORDS</H2><PRE>
frame, menu, menubutton, entries, help
</PRE>
</BODY>
</HTML>
|