''From the [bind] man page:'' Some mice on the Windows platform support a mouse wheel which is used for scrolling documents without using the scrollbars. By rolling the wheel, the system will generate MouseWheel events that the application can use to scroll. Like Key events the event is always routed to the window that currently has focus. When the event is received you can use the %D substitution to get the delta field for the event which is a integer value of motion that the mouse wheel has moved. The smallest value for which the system will report is defined by the OS. On Windows 95 & 98 machines this value is at least 120 before it is reported. However, higher resolution devices may be available in the future. The sign of the value determines which direction your widget should scroll. Positive values should scroll up and negative values should scroll down. Example binding to scroll a canvas (in [a little XML browser]) up or down: bind .t.c {%W yview scroll [expr {-%D/120}] units} Dividing by 120 leads to scrolling one line per wheel click (minimum effective wheel movement) - use a smaller divisor if you want to scroll faster. ([RS]) By "cubing" the number of units, you have the effect that slow turning of the whell moves slowly, while fast turning lets you jump up or down: bind .t.c {%W yview scroll [expr {int(pow(%D/-120,3))}] units} ---- [rmax] AFAIK, works on Windows only. On X you have to bind to the and events. - IIRC, Button-4/5 is even not the only way of mapping the mose wheel on X. As X doesn't support mouse wheels natively, there are at least three different possible mappings floating around, but I don't currently tremember the other two. ---- [KBK] Note that on Windows, the events don't go to the window that contains the mouse pointer, but rather the window that has the ''keyboard'' focus. For various arcane reasons, this behavior is The Right Thing, but it surprises most programmers the first time they see it. Also, note that directing the events to the window with the focus means that the window that is to be scrolled must be able to take the focus. ---- '''Font resizing via mousewheel:''' The following binding reconfigures a widget with -font attribute (e.g. [text], [message], [entry] ...) according to mousewheel rotation: pack [text .t -font {Helvetica 10} -wrap word -width 30 -height 10] .t insert end "This is a little demo text to test the font sizing via mousewheel" catch {bind .t { set font [%W cget -font] set fs [expr {[lindex $font 1]+%D/120}] %W config -font [lreplace $font 1 1 $fs] }} I've added the [catch] because on older Windows versions this event is not supported. Also, the default font does not scale in fine steps - but by specifying one that is implemented as TrueType, the effect is really nice ;-) [RS] ---- [Tk syntax help] | [Arts and crafts of Tcl-Tk programming]