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