summaryrefslogtreecommitdiffstats
path: root/library/scrlbar.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'library/scrlbar.tcl')
-rw-r--r--library/scrlbar.tcl32
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 --