diff options
author | vincentdarley <vincentdarley> | 2004-09-24 14:03:53 (GMT) |
---|---|---|
committer | vincentdarley <vincentdarley> | 2004-09-24 14:03:53 (GMT) |
commit | 00f74438c9deed2111133ed89d2fedab3ff1990d (patch) | |
tree | 069b4e62db5ef0c19eb61ef7427faa10ad7e6f53 /library | |
parent | 7eb9084b9e65b063d1fea59837f705050fa2847e (diff) | |
download | tk-00f74438c9deed2111133ed89d2fedab3ff1990d.zip tk-00f74438c9deed2111133ed89d2fedab3ff1990d.tar.gz tk-00f74438c9deed2111133ed89d2fedab3ff1990d.tar.bz2 |
fix to mousewheel scrolling
Diffstat (limited to 'library')
-rw-r--r-- | library/text.tcl | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/library/text.tcl b/library/text.tcl index fc40aeb..3d3a219 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -3,7 +3,7 @@ # This file defines the default bindings for Tk text widgets and provides # procedures that help in implementing the bindings. # -# RCS: @(#) $Id: text.tcl,v 1.33 2004/09/10 12:13:42 vincentdarley Exp $ +# RCS: @(#) $Id: text.tcl,v 1.34 2004/09/24 14:04:03 vincentdarley Exp $ # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1997 Sun Microsystems, Inc. @@ -452,8 +452,19 @@ set ::tk::Priv(prevPos) {} # on other platforms. We must be careful not to round -ve values of %D # down to zero. +# We must make sure that positive and negative movements are rounded +# equally to integers, avoiding the problem that +# (int)1/3 = 0, +# but +# (int)-1/3 = -1 +# The following code ensure equal +/- behaviour. bind Text <MouseWheel> { - %W yview scroll [expr {-%D}] pixels + puts stderr %D + if {%D >= 0} { + %W yview scroll [expr {-%D/3}] pixels + } else { + %W yview scroll [expr {(2-%D)/3}] pixels + } } if {[string equal [tk windowingsystem] "aqua"]} { bind Text <Option-MouseWheel> { |