"Fossies" - the Fresh Open Source Software archive

Member "Tix8.4.3/docs/html/TixBook/subsubsectionstar3_3_2_3.html" of archive Tix8.4.3-src.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. Alternatively you can here view or download the uninterpreted source code. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.



Next: Validating User Inputs Up: Getting Started: the Previous: 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.