summaryrefslogtreecommitdiffstats
path: root/library/demos
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-10-21 15:58:38 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-10-21 15:58:38 (GMT)
commit6b7a70d3adc1fa78b3cfee9baa8e1f25d27eef8b (patch)
tree2d0f5a68a7cf610466bd4e1f134baf9cf9ad6aa5 /library/demos
parent06bdf94419612cb578502cf30fa89ef013ecebc2 (diff)
downloadtk-6b7a70d3adc1fa78b3cfee9baa8e1f25d27eef8b.zip
tk-6b7a70d3adc1fa78b3cfee9baa8e1f25d27eef8b.tar.gz
tk-6b7a70d3adc1fa78b3cfee9baa8e1f25d27eef8b.tar.bz2
Adapt some demo's to TIP #474 (runtime switchable, depending on Tk version)
,
Diffstat (limited to 'library/demos')
-rw-r--r--library/demos/cscroll.tcl28
-rw-r--r--library/demos/ctext.tcl2
-rw-r--r--library/demos/floor.tcl2
-rw-r--r--library/demos/goldberg.tcl12
-rw-r--r--library/demos/items.tcl2
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 <Enter> "scrollEnter $c"
$c bind all <Leave> "scrollLeave $c"
$c bind all <Button-1> "scrollButton $c"
-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} {
@@ -88,7 +88,11 @@ if {[tk windowingsystem] eq "aqua"} {
}
}
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} {
@@ -98,11 +102,15 @@ if {[tk windowingsystem] eq "aqua"} {
}
}
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
+ }
}
}
-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 <Return> "textInsert $c \\n"
$c bind text <Control-h> "textBs $c"
$c bind text <BackSpace> "textBs $c"
$c bind text <Delete> "textDel $c"
-if {[tk windowingsystem] eq "aqua"} {
+if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} {
$c bind text <Button-3> "textPaste $c @%x,%y"
} else {
$c bind text <Button-2> "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 <Button-1> "floorDisplay $c 2"
$c bind floor3 <Button-1> "floorDisplay $c 3"
$c bind room <Enter> "newRoom $c"
$c bind room <Leave> {set currentRoom ""}
-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"
} 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 <Button-3> [list $w.pause invoke]
bind $w.c <Destroy> {
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 <Button-3> {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 <Button-1> 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 <Button-1> 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 <Button-1> [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 <Button-1> {}
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 <Enter> "itemEnter $c"
$c bind item <Leave> "itemLeave $c"
-if {[tk windowingsystem] eq "aqua"} {
+if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} {
bind $c <Button-2> "itemMark $c %x %y"
bind $c <B2-Motion> "itemStroke $c %x %y"
bind $c <Button-3> "$c scan mark %x %y"