Gnocl Cookbook‎ > ‎

Creating Text Rollover Effects

The basic Gtk textview object does not offer much by way of events notification for text tags. It would be useful if the core signals offered some other events notifications apart from 'motion'. Some sort of 'enter' and 'leave' would have been useful. However, this functionality is provided in the gnocl::text implementation and the following code snippet show it at work.

# tagRollover.tcl

# the next line restarts using tclsh \
exec tclsh "$0" "$@"

package require Gnocl

set text [gnocl::text -margins 4 -rollOverMode both -rollOverFgColor red -rollOverBgColor yellow]

for {set j 0} {$j <= 5 } {incr j} {
 # create new, rollOver tag
 $text tag create _tag_rollOver_$j -rollOver 1 -fontWeight bold

 # use it
 $text insert end "This is "
 $text insert end "Gnocl tag $j" -tags _tag_rollOver_$j
 $text insert end "! \n"

gnocl::window -title "Text TagRollover Effects" -child $text -setSize 0.25