subsection3_3_3.html
subsection3_3_2.html
subsubsectionstar3_3_2_3.html
tableofcontents3_1.html
Next:
subsection3_3_3.html
Accessing The Components
Up:
subsection3_3_2.html
Getting Started: the
Previous:
subsubsectionstar3_3_2_3.html
Disabling Callbacks Temporarily
Validating User Inputs
Sometimes it may be necessary to check the user input against certain
criteria. For example, you may want to allow only even numbers in a
TixControl widget. To do this, you can use the
-validatecmd
option,
which specifies a Tcl command to call whenever the user enters a new
value. Here is an example:
tixControl .c -value 0 -step 2 -validatecmd evenOnly
proc evenOnly {value} {
return [expr $value - ($value %2)]
}
The value parameter to
evenOnly
is the new value entered by
the user.  The
evenOnly
procedure makes sure that the new
value is even by returning a modified, even number. The Tcl command
specified by the
-validatecmd
must return a value which it
deems valid and this value will be stored in the
-value
option
of the TixControl widget.
http://tix.sourceforge.net
http://tix.sourceforge.net
