1<TITLE>optionmenu - Create and manipulate a option menu widget</TITLE> 2<H1>optionmenu - Create and manipulate a option menu widget</H1> 3 4</pre><H2>SYNOPSIS</H2> 5<B>optionmenu<I> <I>pathName </I>?<I>options</I>? 6</pre><H2>INHERITANCE</H2> 7itk::Widget <- Labeledwidget <- optionmenu 8</pre><H2>STANDARD OPTIONS</H2> 9<P> 10<table cellpadding=5> 11<td valign=top> 12<B>activeBackground</B><br> 13<B>borderWidth</B><br> 14<B>foreground</B><br> 15</td> 16<td valign=top> 17<B>activeBorderWidth</B><br> 18<B>cursor</B><br> 19<B>highlightColor</B><br> 20</td> 21<td valign=top> 22<B>activeForeground</B><br> 23<B>disabledForeground</B><br> 24<B>highlightThickness</B><br> 25</td> 26<td valign=top> 27<B>background</B><br> 28<B>font</B><br> 29<B>relief</B><br> 30</td> 31</table> 32<P> 33See the <A HREF="http://www.sco.com/Technology/tcl/man/tk_man/options.n.html"> "options" </A> manual entry for details on the standard options. 34</pre><H2>INHERITED OPTIONS</H2> 35<P> 36<table cellpadding=5> 37<td valign=top> 38<B>disabledForeground</B><br> 39<B>labelMargin</B><br> 40<B>state</B><br> 41</td> 42<td valign=top> 43<B>labelBitmap</B><br> 44<B>labelPos</B><br> 45</td> 46<td valign=top> 47<B>labelFont</B><br> 48<B>labelText</B><br> 49</td> 50<td valign=top> 51<B>labelImage</B><br> 52<B>labelVariable</B><br> 53</td> 54</table> 55<P> 56See the "LabeledWidget" manual entry for details on the inherited options. 57</pre><H2>WIDGET-SPECIFIC OPTIONS</H2> 58<P> 59<pre> 60Name: <B>clickTime</B> 61Class: <B>ClickTime</B> 62Command-Line Switch: <B>-clicktime</B> 63</pre> 64<UL> 65Interval time, in msec, used to determine that a single mouse 66click has occurred. Used to post menu on a "quick" mouse click. 67<B>Note</B>: changing this value may cause the sigle-click 68functionality to not work properly. The default is 150 msec. 69</UL> 70<P> 71<pre> 72Name: <B>command</B> 73Class: <B>Command</B> 74Command-Line Switch: <B>-command</B> 75</pre> 76<UL> 77Specifies a Tcl command procedure to be evaluated following a change in 78the current option menu selection. 79</UL> 80<P> 81<pre> 82Name: <B>cyclicOn</B> 83Class: <B>CyclicOn</B> 84Command-Line Switch: <B>-cyclicon</B> 85</pre> 86<UL> 87Turns on/off the 3rd mouse button capability. The value may be specified 88in any of the forms acceptable to <B>Tcl_GetBoolean</B>. This feature 89allows the right mouse button to cycle through the popup 90menu list without poping it up. The right mouse button cycles through 91the menu in reverse order. The default is true. 92</UL> 93<P> 94<pre> 95Name: <B>popupCursor</B> 96Class: <B>Cursor</B> 97Command-Line Switch: <B>-popupcursor</B> 98</pre> 99<UL> 100Specifies the mouse cursor to be used for the popup menu. The value may 101have any of the forms acceptable to <B>Tk_GetCursor</B>. 102</UL> 103<P> 104<pre> 105Name: <B>state</B> 106Class: <B>State</B> 107Command-Line Switch: <B>-state</B> 108</pre> 109<UL> 110Specified one of two states for the optionmenu: <B>normal</B>, or 111<B>disabled</B>. If the optionmenu is disabled, then option menu 112selection is ignored. 113</UL> 114<P> 115<pre> 116Name: <B>width</B> 117Class: <B>Width</B> 118Command-Line Switch: <B>-width</B> 119</pre> 120<UL> 121Specifies a fixed size for the menu button label in any of the forms 122acceptable to \Tk_GetPixels</B></I>. If the text 123is too small to fit in the label, the text is clipped. 124Note: Normally, when a new list is created, or new items are 125added to an existing list, the menu button label is resized 126automatically. Setting this option overrides that functionality. 127</UL> 128<P> 129</pre><HR> 130 131</pre><H2>DESCRIPTION</H2> 132<P> 133The <B>optionmenu</B> command creates an option menu widget with options 134to manage it. An option menu displays a frame containing a label and a button. 135A pop-up menu will allow for the value of the button to change. 136 137</pre><H2>METHODS</H2> 138<P> 139The <B>optionmenu</B> command creates a new Tcl command whose 140name is <I>pathName</I>. This 141command may be used to invoke various 142operations on the widget. It has the following general form: 143<pre> 144<I>pathName option </I>?<I>arg arg ...</I>? 145</pre> 146<I>Option</I> and the <I>arg</I>s 147determine the exact behavior of the command. 148<P> 149Many of the widget commands for an optionmenu take as one argument an 150indicator of which entry of the option menu to operate on. These 151indicators are called <I>index</I>es and may be specified in 152any of the following forms: 153<DL> 154<DT> <I>number</I> 155</I></B> 156<DD> Specifies the entry numerically, where 0 corresponds 157to the top-most entry of the option menu, 1 to the entry below it, and 158so on. 159</DL> 160<DL> 161<DT> <B>end</B> 162</I></B> 163<DD> Indicates the bottommost entry in the menu. If there are no 164entries in the menu then -1 is returned. 165</DL> 166<DL> 167<DT> <B>select</B> 168</I></B> 169<DD> Returns the numerical index of the currently selected option menu entry. 170If no entries exist in the menu, then -1 is returned. 171</DL> 172<DL> 173<DT> <I>pattern</I> 174</I></B> 175<DD> If the index doesn't satisfy one of the above forms then this 176form is used. <I>Pattern</I> is pattern-matched against the label of 177each entry in the option menu, in order from the top down, until a 178matching entry is found. The rules of <B>Tcl_StringMatch</B> 179are used. 180</DL> 181<P> 182The following widget commands are possible for optionmenu widgets: 183 184</pre><H2>WIDGET-SPECIFIC METHODS</H2> 185<DL> 186<DT> <I>pathName <B>cget</B> <I>option</I> 187</I></B> 188<DD> Returns the current value of the configuration option given 189by <I>option</I>. 190<I>Option</I> may have any of the values accepted by the <B>optionmenu</B> 191command. 192</DL> 193<DL> 194<DT> <I>pathName</I> <B>configure</B> ?<I>option</I>? ?<I>value option value ...</I>? 195</I></B> 196<DD> Query or modify the configuration options of the widget. 197If no <I>option</I> is specified, returns a list describing all of 198the available options for <I>pathName</I> (see <B>Tk_ConfigureInfo</B> for 199information on the format of this list). If <I>option</I> is specified 200with no <I>value</I>, then the command returns a list describing the 201one named option (this list will be identical to the corresponding 202sublist of the value returned if no <I>option</I> is specified). If 203one or more <I>option-value</I> pairs are specified, then the command 204modifies the given widget option(s) to have the given value(s); in 205this case the command returns an empty string. 206<I>Option</I> may have any of the values accepted by the <B>optionmenu</B> 207command. 208</DL> 209<DL> 210<DT> <I>pathName <B>delete <I>first</I> ?<I>last</I>? 211</I></B> 212<DD> Delete all of the option menu entries between <I>first</I> and 213<I>last</I> inclusive. If <I>last</I> is omitted then it defaults 214to <I>first</I>. 215</DL> 216<DL> 217<DT> <I>pathName <B>disable <I>index</I> 218</I></B> 219<DD> Disable the option menu entry specified by <I>index</I>. 220Disabling a menu item will prevent the user from being able to select 221this item from the menu. This only effects the state of the item 222in the menu, in other words, should the item be the currently 223selected item, the programmer is responsible for determining this condition 224and taking appropriate action. 225</DL> 226<DL> 227<DT> <I>pathName <B>enable <I>index</I> 228</I></B> 229<DD> Enable the option menu entry specified by <I>index</I>. 230Enabling a menu item allows the user to select this item from the menu. 231</DL> 232<DL> 233<DT> <I>pathName <B>get</B> ?<I>first</I>? ?<I>last</I>? 234</I></B> 235<DD> If no arguments are specified, this operation returns the currently 236selected option menu item. Otherwise, it returns the name of the 237option at index <I>first</I>, or a range of options between <I>first</I> 238and <I>last</I>. 239</DL> 240<DL> 241<DT> <I>pathName <B>index <I>index</I> 242</I></B> 243<DD> Returns the numerical index corresponding to <I>index</I>. 244</DL> 245<DL> 246<DT> <I>pathName <B>insert <I>index string</I> ?<I>string</I>? 247</I></B> 248<DD> Insert an item, or list of items, into the menu at location <I>index</I>. 249</DL> 250<DL> 251<DT> <I>pathName <B>select <I>index</I> 252</I></B> 253<DD> Select an item from the option menu to be displayed as the currently 254selected item. 255</DL> 256<DL> 257<DT> <I>pathName <B>sort <I>mode</I> 258</I></B> 259<DD> Sort the current menu in either <B>ascending</B>, or <B>descending</B> order. 260The values <B>increasing</B>, or <B>decreasing</B> are also accepted. 261 262</DL> 263</pre><H2>COMPONENTS</H2> 264<P> 265<pre> 266Name: <B>menuBtn</B> 267Class: <B>Menubutton</B> 268</pre> 269<UL> 270The menuBtn component is the option menu button which displays the current 271choice from the popup menu. See the "menubutton" widget manual entry 272for details on the menuBtn component item. 273</UL> 274<P> 275<pre> 276Name: <B>popupMenu</B> 277Class: <B>Menu</B> 278</pre> 279<UL> 280The popupMenu component is menu displayed upon selection of the menu button. 281The menu contains the choices for the option menu. See the "menu" widget 282manual entry for details on the popupMenu component item. 283</UL> 284</table> 285 286</pre><H2>EXAMPLE</H2> 287<pre> 288 optionmenu .om -labelmargin 5 \\ 289 -labelon true -labelpos w -labeltext "Operating System :" 290 291 .om insert end Unix VMS Linux OS/2 {Windows NT} DOS 292 .om sort ascending 293 .om select Linux 294 295 pack .om -padx 10 -pady 10 296</pre> 297</pre><H2>ACKNOWLEDGEMENTS:</H2> 298Michael J. McLennan 299<UL> 300Borrowed some ideas (next & previous) from OptionButton class. 301</UL> 302<P> 303Steven B. Jaggers 304<UL> 305Provided an initial prototype in [incr Tcl]. 306</UL> 307<P> 308Bret Schuhmacher 309<UL> 310Helped with popup menu functionality. 311</UL> 312<P> 313</pre><H2>AUTHOR</H2> 314Alfredo Jahn 315</pre><H2>KEYWORDS</H2> 316optionmenu, widget 317