diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-29 12:05:59 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-29 12:05:59 (GMT) |
commit | 71eb85666db1bf1262bf301935e7d1674cd06661 (patch) | |
tree | 4732c41edd69381776f475cbc0b0f70cf05c9fc7 /library | |
parent | f229cc87ab8e94200976b0233cfe07e5887cea49 (diff) | |
parent | e156e1d87e6eff493352961a0479c5f3630ef481 (diff) | |
download | tk-71eb85666db1bf1262bf301935e7d1674cd06661.zip tk-71eb85666db1bf1262bf301935e7d1674cd06661.tar.gz tk-71eb85666db1bf1262bf301935e7d1674cd06661.tar.bz2 |
Merge trunk.
Tweak bindings in cscroll demo.
Remove comment in text.tcl which is no longer necessary
Diffstat (limited to 'library')
-rw-r--r-- | library/demos/cscroll.tcl | 41 | ||||
-rw-r--r-- | library/text.tcl | 11 |
2 files changed, 17 insertions, 35 deletions
diff --git a/library/demos/cscroll.tcl b/library/demos/cscroll.tcl index 90b1afc..d210c7d 100644 --- a/library/demos/cscroll.tcl +++ b/library/demos/cscroll.tcl @@ -56,44 +56,29 @@ for {set i 0} {$i < 20} {incr i} { $c bind all <Enter> "scrollEnter $c" $c bind all <Leave> "scrollLeave $c" $c bind all <Button-1> "scrollButton $c" -if {[package vsatisfies [package provide Tk] 8.7-]} { - bind $c <Button-2> "$c scan mark %x %y" - bind $c <B2-Motion> "$c scan dragto %x %y" - bind $c <MouseWheel> { - tk::MouseWheel %W y %D -30.0 - } - bind $c <Option-MouseWheel> { - tk::MouseWheel %W y %D -3.0 - } - bind $c <Shift-MouseWheel> { - tk::MouseWheel %W x %D -30.0 - } - bind $c <Shift-Option-MouseWheel> { - tk::MouseWheel %W x %D -3.0 - } -} elseif {[tk windowingsystem] eq "aqua"} { +if {([tk windowingsystem] eq "aqua") && ![package vsatisfies [package provide Tk] 8.7-]} { bind $c <Button-3> "$c scan mark %x %y" bind $c <B3-Motion> "$c scan dragto %x %y" bind $c <MouseWheel> { - %W yview scroll [expr {-(%D)}] units + %W yview scroll [expr {-%D}] units } bind $c <Option-MouseWheel> { - %W yview scroll [expr {-10 * (%D)}] units + %W yview scroll [expr {-10*%D}] units } bind $c <Shift-MouseWheel> { - %W xview scroll [expr {-(%D)}] units + %W xview scroll [expr {-%D}] units } bind $c <Shift-Option-MouseWheel> { - %W xview scroll [expr {-10 * (%D)}] units + %W xview scroll [expr {-10*%D}] units } } else { bind $c <Button-2> "$c scan mark %x %y" bind $c <B2-Motion> "$c scan dragto %x %y" # We must make sure that positive and negative movements are rounded # equally to integers, avoiding the problem that - # (int)1/30 = 0, + # (int)1/-30 = -1, # but - # (int)-1/30 = -1 + # (int)-1/-30 = 0 # The following code ensure equal +/- behaviour. bind $c <MouseWheel> { if {%D >= 0} { @@ -103,7 +88,11 @@ if {[package vsatisfies [package provide Tk] 8.7-]} { } } bind $c <Option-MouseWheel> { - %W yview scroll [expr {%D/-3}] units + if {%D >= 0} { + %W yview scroll [expr {%D/-3}] units + } else { + %W yview scroll [expr {(%D-2)/-3}] units + } } bind $c <Shift-MouseWheel> { if {%D >= 0} { @@ -113,7 +102,11 @@ if {[package vsatisfies [package provide Tk] 8.7-]} { } } bind $c <Shift-Option-MouseWheel> { - %W xview scroll [expr {%D/-3}] units + if {%D >= 0} { + %W xview scroll [expr {%D/-3}] units + } else { + %W xview scroll [expr {(%D-2)/-3}] units + } } } diff --git a/library/text.tcl b/library/text.tcl index f25f639..00806f7 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -441,17 +441,6 @@ bind Text <B2-Motion> { } set ::tk::Priv(prevPos) {} -# The MouseWheel will typically only fire on Windows and MacOS X. -# However, someone could use the "event generate" command to produce one -# 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> { tk::MouseWheel y %D -3.0 pixels } |