diff options
author | marc_culler <marc.culler@gmail.com> | 2023-11-24 03:26:01 (GMT) |
---|---|---|
committer | marc_culler <marc.culler@gmail.com> | 2023-11-24 03:26:01 (GMT) |
commit | aeab7d5c4d1f242492acb6e29416f03bffb7dbf8 (patch) | |
tree | f4e0841cf8e1903fbdbd316c76c026b57be0b5cb | |
parent | 28aff698b1b05951f9d5e29f7bbccc4eaeb91af0 (diff) | |
download | tk-aeab7d5c4d1f242492acb6e29416f03bffb7dbf8.zip tk-aeab7d5c4d1f242492acb6e29416f03bffb7dbf8.tar.gz tk-aeab7d5c4d1f242492acb6e29416f03bffb7dbf8.tar.bz2 |
Fix the regression in scrlbar.tcl
-rw-r--r-- | library/scrlbar.tcl | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl index 3ef9deb..32e02f2 100644 --- a/library/scrlbar.tcl +++ b/library/scrlbar.tcl @@ -140,10 +140,10 @@ bind Scrollbar <MouseWheel> { bind Scrollbar <Control-MouseWheel> { lassign [tk::PreciseScrollDeltas %D] deltaX deltaY if {$deltaX != 0} { - ScrollbarScrollByPixels %W h $deltaX + ScrollByPixels %W h $deltaX } if {$deltaY != 0} { - ScrollbarScrollByPixels %W v $deltaY + ScrollByPixels %W v $deltaY } } @@ -307,7 +307,7 @@ proc ::tk::ScrollEndDrag {w x y} { set Priv(initPos) "" } -# ScrollbarScrollByPixels -- +# ScrollByPixels -- # This procedure tells the scrollbar's associated widget to scroll up # or down by a given number of pixels. It only works with scrollbars # because it uses the delta command. @@ -318,24 +318,36 @@ proc ::tk::ScrollEndDrag {w x y} { # horizontal, "v" for vertical. # amount - How many pixels to scroll. -proc ScrollbarScrollByPixels {sb orient amount} { - set cmd [$sb cget -command] +proc ScrollByPixels {w orient amount} { + set cmd [$w cget -command] if {$cmd eq ""} { return } set xyview [lindex [split $cmd] end] - if {$orient eq "v" && $xyview eq "xview" || \ - $orient eq "h" && $xyview eq "yview"} { - return + if {$orient eq "v"} { + if {$xyview eq "xview"} { + return + } + set size [winfo height $w] + } + if {$orient eq "h"} { + if {$xyview eq "yview"} { + return + } + set size [winfo width $w] } - set info [$sb get] + + # The code below works with both the current and old syntax for + # the scrollbar get command. + + set info [$w get] if {[llength $info] == 2} { set first [lindex $info 0] } else { set first [lindex $info 2] } set pixels [expr {-$amount}] - uplevel #0 $cmd moveto [expr $first + [$sb delta $pixels $pixels]] + uplevel #0 $cmd moveto [expr $first + [$w delta $pixels $pixels]] } # ::tk::ScrollByUnits -- |