Next: The TixSelect Widget Up: Another Tix Widget: Previous: Static Options

### Monitoring the User's Browsing Actions

When the user drags the mouse pointer over the listbox, the listbox item under the pointer will be highlighted and a ``browse event'' will be generated. If you want to keep track of what items the user has browses through, you can use the `-browsecmd` option. Here is an example:

`tixComboBox .c -browsecmd mybrowse
....
proc mybrowse {item} {
puts "user has browsed $item"
}`

When the Tcl command specified by the `-browsecmd` option is called, it will be called with one parameter: the current item that the user has highlighted.

The `-browsecmd` is useful because it gives the user the possibility of temporarily seeing the results of several choices before committing to a final choice.

For example, we can list a set of image files in a ComboBox. When the user single-clicks on an item on the ComboBox, we want to show a simplified view of that image. After the user has browsed through several images, he can finally decide on which image he wants by double-clicking on that item in the listbox.

The following is some pseudo Tcl code that does this. Please notice that the `-browsecmd` procedure is called every time the user single-clicks on an item or drags the mouse pointer in the listbox. The `-command` procedure is only called when the user double-clicks on an item.

`tixComboBox .c -dropdown false -browsecmd show_simple -command load_fullsize
.c insert end "/pkg/images/flowers.gif"
.c insert end "/pkg/images/jimmy.gif"
.c insert end "/pkg/images/ncsa.gif"
proc show_simple {filename} {
# Load in a simplified version of $filename
}
proc load_fullsize {filename} {
# Load in the full size image in $filename
}`

As we shall see, all Tix widgets that let us do some sort of selections have the `-browsecmd` option. The `-browsecmd` option allows us to respond to user events in a simple, straight-forward manner. Of course, you can do the same thing with the Tk `bind` command, but you don't want to do that unless you are very fond of things like `$<$Control-Shift-ButtonRelease-1$>$` and `"%x%X$w%W%w"`.