From: Neil M. <ne...@cs...> - 2004-02-07 01:32:14
|
I was just playing with a text widget and scrollbar on Tcl/Tk Aqua, and it seems that the scroll-wheel implementation is partially broken. Is this a known bug? Basically, I can use the mouse wheel to scroll down the widget, but not up. A small test script which demonstrates the problem: pack [scrollbar .vsb -orient vertical -command [list .t yview]] -side right -fill y pack [text .t -yscrollcommand [list .vsb set]] -fill both -expand 1 for {set i 0} {$i < 100} {incr i} { .t insert end "$i\n" } Now when you use the mouse wheel, you can scroll down, but not up. This is using the wish 8.4.5 from the recent TclTkAquaBI distro. ... A little more digging, and I think I've found the cause. The Text class has the following binding for <MouseWheel>: %W yview scroll [expr {- (%D / 120) * 4}] units Now, scrolling the wheel up gives delta values between 1 and 21 (for me), whereas down it gives -1 to -21. Using the expr given, 21/120 == 0 (integer arith, round down), whereas -21/120 == -1. I presume this binding is specific to Mac OS X, as I've never had a problem with the mouse wheel on Windows or Linux (although on *nix the bindings are to Button-4/5). Anyway, as I can't get delta values above 120 (or anywhere near it), this expr is never going to work. Does anyone get large values for delta on Mac OS X? If not, I suggest changing the binding to something more like: %W yview scroll [expr { - round(%D/5.0)}] units which seems to work ok for me (note the use of round()). If this is a new bug, should I submit it somewhere? Do Mac OS X Tk bugs get tracked at the usual Tk bug tracker, or in a separate project? Cheers, Neil. |