diff options
Diffstat (limited to 'library/demos/cscroll.tcl')
-rw-r--r-- | library/demos/cscroll.tcl | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/library/demos/cscroll.tcl b/library/demos/cscroll.tcl index c0c30ee..d210c7d 100644 --- a/library/demos/cscroll.tcl +++ b/library/demos/cscroll.tcl @@ -56,45 +56,61 @@ 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" -bind $c <Button-2> "$c scan mark %x %y" -bind $c <B2-Motion> "$c scan dragto %x %y" -if {[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} { - %W yview scroll [expr {-%D/30}] units + %W yview scroll [expr {%D/-30}] units } else { - %W yview scroll [expr {(29-%D)/30}] units + %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> { if {%D >= 0} { - %W xview scroll [expr {-%D/30}] units + %W xview scroll [expr {%D/-30}] units } else { - %W xview scroll [expr {(29-%D)/30}] units + %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: @@ -119,18 +135,6 @@ if {[tk windowingsystem] eq "x11"} { %W xview scroll 5 units } } - if {[package vsatisfies [package provide Tk] 8.7]} { - bind $c <Button-6> { - if {!$tk_strictMotif} { - %W xview scroll -5 units - } - } - bind $c <Button-7> { - if {!$tk_strictMotif} { - %W xview scroll 5 units - } - } - } } |