1iwidgets::optionmenu − Create and manipulate a option menu widget

iwidgets::optionmenu pathName ?options? itk::Widget <‐ iwid‐

3gets::Labeledwidget <‐ iwidgets::Optionmenu

activeBackground activeBorderWidth activeForeground background

borderWidth cursor disabledForeground font

foreground highlightColor highlightThickness relief

7See  the  "options"  manual entry for details on the standard op‐
8tions.

disabledForeground labelBitmap labelFontlabelImage

labelMargin labelPos labelText labelVariable

state sticky

12See the "LabeledWidget" manual entry for details on the inherited
13options.
14Name:           clickTime
15Class:          ClickTime
16Command‐Line Switch:           ‐clicktime
17Interval  time,  in  msec,  used to determine that a single mouse
18click has occurred. Used to post menu on a "quick"  mouse  click.

Note: changing this value may cause the sigle‐click functionality

20to not work properly.  The default is 150 msec.
21Name:           command
22Class:          Command
23Command‐Line Switch:           ‐command
24Specifies a Tcl command procedure to  be  evaluated  following  a
25change in the current option menu selection.
26Name:           cyclicOn
27Class:          CyclicOn
28Command‐Line Switch:           ‐cyclicon
29Turns  on/off  the  3rd mouse button capability. The value may be
30specified in any of the forms acceptable to Tcl_GetBoolean.  This
31feature  allows the right mouse button to cycle through the popup
32menu list without poping it up. The  right  mouse  button  cycles
33through the menu in reverse order.  The default is true.
34Name:           popupCursor
35Class:          Cursor
36Command‐Line Switch:           ‐popupcursor
37Specifies   the  mouse cursor to be used for the popup menu.  The
38value may have any of the  forms  acceptable to Tk_GetCursor.
39Name:           state
40Class:          State
41Command‐Line Switch:           ‐state
42Specified one of two states for the optionmenu: normal,  or  dis‐

abled. If the optionmenu is disabled, then option menu selection

44is ignored.
45Name:           width
46Class:          Width
47Command‐Line Switch:           ‐width
48Specifies a fixed size for the menu button label in  any  of  the
49forms  acceptable  to  Tk_GetPixels.  If the text is too small to
50fit in the label, the text is clipped.  Note:  Normally,  when  a
51new  list is created, or new items are added to an existing list,
52the menu button label is resized automatically.  Setting this op‐
53tion overrides that functionality.
54
55The  iwidgets::optionmenu  command  creates an option menu widget
56with options to manage it.  An option menu displays a frame  con‐
57taining  a  label and a button.  A pop‐up menu will allow for the
58value of the button to change.
59
60The iwidgets::optionmenu command creates a new Tcl command  whose
61name is pathName.  This command may be used to invoke various op‐
62erations on the widget.  It has the following general form: path‐

Name option ?arg arg ...? Option and the args determine the ex‐

64act behavior of the command.  Many of the widget commands for  an
65optionmenu  take  as  one argument an indicator of which entry of
66the option menu to operate on.  These indicators are  called  in‐

dexes and may be specified in any of the following forms: number

68Specifies the entry numerically, where 0 corresponds to the  top‐
69most  entry  of  the option menu, 1 to the entry below it, and so
70on.  end Indicates the bottommost entry in the  menu.   If  there
71are  no  entries in the menu then ‐1 is returned.  select Returns
72the numerical index of the currently selected option menu  entry.
73If no entries exist in the menu, then ‐1 is returned.  pattern If
74the index doesn’t satisfy one of the above forms then  this  form
75is  used.   Pattern  is pattern‐matched against the label of each
76entry in the option menu, in order from the  top  down,  until  a
77matching  entry is found.  The rules of Tcl_StringMatch are used.
78The following widget commands are possible  for  optionmenu  wid‐
79gets:
80

pathName cget option Returns the current value of the configura‐

82tion option given by option.  Option may have any of  the  values
83accepted by the iwidgets::optionmenu command.  pathName configure
84?option? ?value option value ...?  Query or modify the configura‐
85tion options of the widget.  If no option is specified, returns a
86list describing all of the available options  for  pathName  (see

Tk_ConfigureInfo for information on the format of this list). If

option is specified with no value, then the command returns a

89list describing the one named option (this list will be identical
90to the corresponding sublist of the value returned if  no  option
91is  specified).  If one or more option−value pairs are specified,
92then the command modifies the given widget option(s) to have  the
93given  value(s);   in  this  case  the  command  returns an empty
94string.  Option may have any of the values accepted by the  iwid‐

gets::optionmenu command. pathName delete first ?last? Delete

96all of the option menu entries between first and last  inclusive.
97If  last  is omitted then it defaults to first.  pathName disable

index Disable the option menu entry specified by index. Dis‐

99abling  a  menu item will prevent the user from being able to se‐
100lect this item from the menu.  This only effects the state of the
101item in the menu, in other words, should the item be the current‐
102ly selected item, the programmer is responsible  for  determining
103this  condition  and  taking appropriate action.  pathName enable

index Enable the option menu entry specified by index. Enabling

105a  menu  item  allows the user to select this item from the menu.

pathName get ?first? ?last? If no arguments are specified, this

107operation  returns the currently selected option menu item.  Oth‐
108erwise, it returns the name of the option at index  first,  or  a
109range  of  options  between first and last.  pathName index index
110Returns the numerical index corresponding to index.  pathName in‐

sert index string ?string? Insert an item, or list of items, in‐

112to the menu at location index.  pathName select index  Select  an
113item  from  the  option menu to be displayed as the currently se‐
114lected item.  pathName sort mode Sort the current menu in  either

ascending, or descending order. The values increasing, or de‐

creasing are also accepted.

117
118Name:           menuBtn
119Class:          Menubutton
120The menuBtn component is the option menu  button  which  displays
121the  current  choice  from  the popup menu.  See the "menubutton"
122widget manual entry for details on the menuBtn component item.
123Name:           popupMenu
124Class:          Menu
125The popupMenu component is menu displayed upon selection  of  the
126menu  button.  The menu contains the choices for the option menu.
127See the "menu" widget manual entry for details on  the  popupMenu
128component item.
129
130 package require Iwidgets 4.0
131 iwidgets::optionmenu .om ‐labelmargin 5 \
132     ‐labelon true ‐labelpos w ‐labeltext "Operating System :"
133
134 .om insert end Unix VMS Linux OS/2 {Windows NT} DOS
135 .om sort ascending
136 .om select Linux
137
138 pack  .om   ‐padx  10 ‐pady 10 Michael J. McLennan Borrowed some
139ideas (next & previous) from OptionButton class.  Steven B.  Jag‐
140gers  Provided  an  initial prototype in [incr Tcl].  Bret Schuh‐
141macher Helped with popup menu functionality.   Alfredo  Jahn  op‐
142tionmenu, widget
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
Impressum