diff options
author | dgp <dgp@users.sourceforge.net> | 2014-11-07 14:20:14 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2014-11-07 14:20:14 (GMT) |
commit | fcc39af8d8691cdcc0ce49efe09ad61b94da9ba0 (patch) | |
tree | 16e75caa03c5f8899171780cf48367d294c3c2c1 | |
parent | ba46065bdddd77146da41ff64ffd1f6dce7189e1 (diff) | |
parent | 047316eaff14d14c10caa5f0742c426f3963c60b (diff) | |
download | tk-fcc39af8d8691cdcc0ce49efe09ad61b94da9ba0.zip tk-fcc39af8d8691cdcc0ce49efe09ad61b94da9ba0.tar.gz tk-fcc39af8d8691cdcc0ce49efe09ad61b94da9ba0.tar.bz2 |
[3529885] [scale] handle negative resolution properly.
-rw-r--r-- | library/scale.tcl | 8 | ||||
-rw-r--r-- | tests/scale.test | 33 |
2 files changed, 40 insertions, 1 deletions
diff --git a/library/scale.tcl b/library/scale.tcl index b4da824..771c7a4 100644 --- a/library/scale.tcl +++ b/library/scale.tcl @@ -223,7 +223,13 @@ proc ::tk::ScaleIncrement {w dir big repeat} { set inc [$w cget -resolution] } if {([$w cget -from] > [$w cget -to]) ^ ($dir eq "up")} { - set inc [expr {-$inc}] + if {$inc > 0} { + set inc [expr {-$inc}] + } + } else { + if {$inc < 0} { + set inc [expr {-$inc}] + } } $w set [expr {[$w get] + $inc}] diff --git a/tests/scale.test b/tests/scale.test index d7ded7f..73d0f2d 100644 --- a/tests/scale.test +++ b/tests/scale.test @@ -867,6 +867,39 @@ test scale-18.3 {Scale button 2 events [Bug 787065]} \ } \ -result {0 {}} +test scale-19 {Bug [3529885fff] - Click in through goes in wrong direction} \ + -setup { + catch {destroy .s} + catch {destroy .s1 .s2 .s3 .s4} + scale .s1 -from 0 -to 100 -resolution 1 -variable x1 -digits 4 -orient horizontal -length 100 + scale .s2 -from 0 -to 100 -resolution -1 -variable x2 -digits 4 -orient horizontal -length 100 + scale .s3 -from 100 -to 0 -resolution 1 -variable x3 -digits 4 -orient horizontal -length 100 + scale .s4 -from 100 -to 0 -resolution -1 -variable x4 -digits 4 -orient horizontal -length 100 + pack .s1 .s2 .s3 .s4 -side left + update + } \ + -body { + foreach {x y} [.s1 coord 50] {} + event generate .s1 <1> -x $x -y $y + event generate .s1 <ButtonRelease-1> -x $x -y $y + foreach {x y} [.s2 coord 50] {} + event generate .s2 <1> -x $x -y $y + event generate .s2 <ButtonRelease-1> -x $x -y $y + foreach {x y} [.s3 coord 50] {} + event generate .s3 <1> -x $x -y $y + event generate .s3 <ButtonRelease-1> -x $x -y $y + foreach {x y} [.s4 coord 50] {} + event generate .s4 <1> -x $x -y $y + event generate .s4 <ButtonRelease-1> -x $x -y $y + update + list $x1 $x2 $x3 $x4 + } \ + -cleanup { + unset x1 x2 x3 x4 x y + destroy .s1 .s2 .s3 .s4 + } \ + -result {1.0 1.0 1.0 1.0} + catch {destroy .s} option clear |