diff options
Diffstat (limited to 'Master/tlpkg/tltcl/lib/tk8.6/demos/cscroll.tcl')
-rw-r--r-- | Master/tlpkg/tltcl/lib/tk8.6/demos/cscroll.tcl | 64 |
1 files changed, 47 insertions, 17 deletions
diff --git a/Master/tlpkg/tltcl/lib/tk8.6/demos/cscroll.tcl b/Master/tlpkg/tltcl/lib/tk8.6/demos/cscroll.tcl index 443b102bef0..d210c7df720 100644 --- a/Master/tlpkg/tltcl/lib/tk8.6/demos/cscroll.tcl +++ b/Master/tlpkg/tltcl/lib/tk8.6/demos/cscroll.tcl @@ -53,54 +53,84 @@ for {set i 0} {$i < 20} {incr i} { } } -$c bind all <Any-Enter> "scrollEnter $c" -$c bind all <Any-Leave> "scrollLeave $c" -$c bind all <1> "scrollButton $c" -bind $c <2> "$c scan mark %x %y" -bind $c <B2-Motion> "$c scan dragto %x %y" -if {[tk windowingsystem] eq "aqua"} { +$c bind all <Enter> "scrollEnter $c" +$c bind all <Leave> "scrollLeave $c" +$c bind all <Button-1> "scrollButton $c" +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 = -1, + # but + # (int)-1/-30 = 0 + # The following code ensure equal +/- behaviour. bind $c <MouseWheel> { - %W yview scroll [expr {-(%D / 30)}] units + if {%D >= 0} { + %W yview scroll [expr {%D/-30}] units + } else { + %W yview scroll [expr {(%D-29)/-30}] units + } + } + bind $c <Option-MouseWheel> { + if {%D >= 0} { + %W yview scroll [expr {%D/-3}] units + } else { + %W yview scroll [expr {(%D-2)/-3}] units + } } bind $c <Shift-MouseWheel> { - %W xview scroll [expr {-(%D / 30)}] units + if {%D >= 0} { + %W xview scroll [expr {%D/-30}] units + } else { + %W xview scroll [expr {(%D-29)/-30}] units + } + } + bind $c <Shift-Option-MouseWheel> { + if {%D >= 0} { + %W xview scroll [expr {%D/-3}] units + } else { + %W xview scroll [expr {(%D-2)/-3}] units + } } } -if {[tk windowingsystem] eq "x11"} { +if {[tk windowingsystem] eq "x11" && ![package vsatisfies [package provide Tk] 8.7-]} { # Support for mousewheels on Linux/Unix commonly comes through mapping # the wheel to the extended buttons. If you have a mousewheel, find # Linux configuration info at: # http://linuxreviews.org/howtos/xfree/mouse/ - bind $c <4> { + bind $c <Button-4> { if {!$tk_strictMotif} { %W yview scroll -5 units } } - bind $c <Shift-4> { + bind $c <Shift-Button-4> { if {!$tk_strictMotif} { %W xview scroll -5 units } } - bind $c <5> { + bind $c <Button-5> { if {!$tk_strictMotif} { %W yview scroll 5 units } } - bind $c <Shift-5> { + bind $c <Shift-Button-5> { if {!$tk_strictMotif} { %W xview scroll 5 units } |