From 6b7a70d3adc1fa78b3cfee9baa8e1f25d27eef8b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 21 Oct 2020 15:58:38 +0000 Subject: Adapt some demo's to TIP #474 (runtime switchable, depending on Tk version) , --- library/demos/cscroll.tcl | 28 ++++++++++++++++++---------- library/demos/ctext.tcl | 2 +- library/demos/floor.tcl | 2 +- library/demos/goldberg.tcl | 12 ++++++------ library/demos/items.tcl | 2 +- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/library/demos/cscroll.tcl b/library/demos/cscroll.tcl index f64ca5d..d210c7d 100644 --- a/library/demos/cscroll.tcl +++ b/library/demos/cscroll.tcl @@ -56,29 +56,29 @@ for {set i 0} {$i < 20} {incr i} { $c bind all "scrollEnter $c" $c bind all "scrollLeave $c" $c bind all "scrollButton $c" -if {[tk windowingsystem] eq "aqua"} { +if {([tk windowingsystem] eq "aqua") && ![package vsatisfies [package provide Tk] 8.7-]} { bind $c "$c scan mark %x %y" bind $c "$c scan dragto %x %y" bind $c { - %W yview scroll [expr {-(%D)}] units + %W yview scroll [expr {-%D}] units } bind $c { - %W yview scroll [expr {-10 * (%D)}] units + %W yview scroll [expr {-10*%D}] units } bind $c { - %W xview scroll [expr {-(%D)}] units + %W xview scroll [expr {-%D}] units } bind $c { - %W xview scroll [expr {-10 * (%D)}] units + %W xview scroll [expr {-10*%D}] units } } else { bind $c "$c scan mark %x %y" bind $c "$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 { if {%D >= 0} { @@ -88,7 +88,11 @@ if {[tk windowingsystem] eq "aqua"} { } } bind $c { - %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 { if {%D >= 0} { @@ -98,11 +102,15 @@ if {[tk windowingsystem] eq "aqua"} { } } bind $c { - %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 + } } } -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: diff --git a/library/demos/ctext.tcl b/library/demos/ctext.tcl index 5acc82f..d3fec33 100644 --- a/library/demos/ctext.tcl +++ b/library/demos/ctext.tcl @@ -50,7 +50,7 @@ $c bind text "textInsert $c \\n" $c bind text "textBs $c" $c bind text "textBs $c" $c bind text "textDel $c" -if {[tk windowingsystem] eq "aqua"} { +if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} { $c bind text "textPaste $c @%x,%y" } else { $c bind text "textPaste $c @%x,%y" diff --git a/library/demos/floor.tcl b/library/demos/floor.tcl index 37e1b95..eb2ea7f 100644 --- a/library/demos/floor.tcl +++ b/library/demos/floor.tcl @@ -1359,7 +1359,7 @@ $c bind floor2 "floorDisplay $c 2" $c bind floor3 "floorDisplay $c 3" $c bind room "newRoom $c" $c bind room {set currentRoom ""} -if {[tk windowingsystem] eq "aqua"} { +if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} { bind $c "$c scan mark %x %y" bind $c "$c scan dragto %x %y" } else { diff --git a/library/demos/goldberg.tcl b/library/demos/goldberg.tcl index 284b5c2..1cc52c6 100644 --- a/library/demos/goldberg.tcl +++ b/library/demos/goldberg.tcl @@ -105,7 +105,7 @@ proc DoDisplay {w} { $w.c yview moveto .05 pack $w.c -in $w.screen -side top -fill both -expand 1 - bind $w.c <3> [list $w.pause invoke] + bind $w.c [list $w.pause invoke] bind $w.c { after cancel $animationCallbacks(goldberg) unset animationCallbacks(goldberg) @@ -162,7 +162,7 @@ proc DoCtrlFrame {w} { grid $w.speed -in $w.ctrl -row 99 -sticky ew -pady {0 5} pack $w.speed.scale -fill both -expand 1 grid $w.about -in $w.ctrl -row 100 -sticky ew - bind $w.reset <3> {set S(mode) -1} ;# Debugging + bind $w.reset {set S(mode) -1} ;# Debugging ## See Code / Dismiss buttons hack! set btns [addSeeDismiss $w.ctrl.buttons $w] @@ -342,7 +342,7 @@ proc Draw0 {w} { set xy {719 119 763 119} $w.c create line $xy -tag I0 -fill $color -width 5 -arrow last \ -arrowshape {18 18 5} - $w.c bind I0 <1> Start + $w.c bind I0 Start } proc Move0 {w {step {}}} { set step [GetStep 0 $step] @@ -372,7 +372,7 @@ proc Draw1 {w} { set xy [box 812 122 9] $w.c create oval $xy -tag I1 -fill $color2 -outline {} - $w.c bind I1 <1> Start + $w.c bind I1 Start } proc Move1 {w {step {}}} { set step [GetStep 1 $step] @@ -1620,7 +1620,7 @@ proc Move26 {w {step {}}} { $w.c delete I24 I26 $w.c create text 430 755 -anchor s -tag I26 \ -text "click to continue" -font {{Times Roman} 24 bold} - bind $w.c <1> [list Reset $w] + bind $w.c [list Reset $w] return 4 } @@ -1675,7 +1675,7 @@ proc RotateC {x y Ox Oy beta} { proc Reset {w} { global S DrawAll $w - bind $w.c <1> {} + bind $w.c {} set S(mode) $::MSTART set S(active) 0 } diff --git a/library/demos/items.tcl b/library/demos/items.tcl index 545877c..1297046 100644 --- a/library/demos/items.tcl +++ b/library/demos/items.tcl @@ -173,7 +173,7 @@ $c create text 28.5c 17.4c -text Scale: -anchor s $c bind item "itemEnter $c" $c bind item "itemLeave $c" -if {[tk windowingsystem] eq "aqua"} { +if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} { bind $c "itemMark $c %x %y" bind $c "itemStroke $c %x %y" bind $c "$c scan mark %x %y" -- cgit v0.12