subsubsection3_3_2_4.html
subsection3_3_2.html
subsubsection3_3_2_2.html
tableofcontents3_1.html
Next:
subsubsection3_3_2_4.html
Validating User Inputs
Up:
subsection3_3_2.html
Getting Started: the
Previous:
subsubsection3_3_2_2.html
Accessing The Value
Disabling Callbacks Temporarily
Now, if you want to change a value from within the program, you have to
disable the callback. The reason is that the callback runs whenever you
(as well as the user) makes a change. In particular, if you make a change
within the callback procedure and forget to disable the callback, it will
recursively call itself and enter an infinite loop. To avoid this
problem, you should use the
-disablecallback
option. Here is an
example:
tixControl .c -command addOne
proc addOne {value} {
.c config -disablecallback true
.c config -value [incr value]
.c config -disablecallback false
}
The procedure
addOne
adjusts the value of
.c
by one whenever
the user enters a new value into
.c
. Notice that it is necessary to
set
-disablecallback
here or otherwise
addOne
will be
infinitely recursed! That is because
addOne
is called
every
time
the value changes, either by the user or by the program.
http://tix.sourceforge.net
http://tix.sourceforge.net
