Mark msysGit as obsolete
[msysgit.git] / mingw / lib / tk8.5 / optMenu.tcl
blob7cfdaa021f3d4a780e12aa3899f9b14efec45fa1
1 # optMenu.tcl --
3 # This file defines the procedure tk_optionMenu, which creates
4 # an option button and its associated menu.
6 # Copyright (c) 1994 The Regents of the University of California.
7 # Copyright (c) 1994 Sun Microsystems, Inc.
9 # See the file "license.terms" for information on usage and redistribution
10 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 # ::tk_optionMenu --
14 # This procedure creates an option button named $w and an associated
15 # menu. Together they provide the functionality of Motif option menus:
16 # they can be used to select one of many values, and the current value
17 # appears in the global variable varName, as well as in the text of
18 # the option menubutton. The name of the menu is returned as the
19 # procedure's result, so that the caller can use it to change configuration
20 # options on the menu or otherwise manipulate it.
22 # Arguments:
23 # w - The name to use for the menubutton.
24 # varName - Global variable to hold the currently selected value.
25 # firstValue - First of legal values for option (must be >= 1).
26 # args - Any number of additional values.
28 proc ::tk_optionMenu {w varName firstValue args} {
29 upvar #0 $varName var
31 if {![info exists var]} {
32 set var $firstValue
34 menubutton $w -textvariable $varName -indicatoron 1 -menu $w.menu \
35 -relief raised -highlightthickness 1 -anchor c \
36 -direction flush
37 menu $w.menu -tearoff 0
38 $w.menu add radiobutton -label $firstValue -variable $varName
39 foreach i $args {
40 $w.menu add radiobutton -label $i -variable $varName
42 return $w.menu