Index: doc/example-scripts/tk-locomotive.html =================================================================== diff -u -rc2374366bcb47c70ebd33cb16c8152eba783987f -r7c692cef773e19f9da59bef6498ba673cdff468e --- doc/example-scripts/tk-locomotive.html (.../tk-locomotive.html) (revision c2374366bcb47c70ebd33cb16c8152eba783987f) +++ doc/example-scripts/tk-locomotive.html (.../tk-locomotive.html) (revision 7c692cef773e19f9da59bef6498ba673cdff468e) @@ -769,6 +769,7 @@
package require Tk
 package require nx
+package require nx::trait
 
 nx::Class create Wheel {
   :property x
@@ -842,6 +843,8 @@
 nx::Class create Locomotive {
   :property {speed 4}
 
+  :require trait nx::traits::callback
+
   :method turn {} {
     set :alpha [expr {round(${:alpha} + 360 - ${:speed}) % 360}]
     foreach i [${:c} find withtag counterweight] {
@@ -903,9 +906,9 @@
     set :c [canvas .c -width 600 -height 160 -background lightblue]
     pack ${:c}
 
-    bind ${:c} <1> [list [self] throttle]
-    bind ${:c} <2> [list [self] break]
-    bind ${:c} <3> [list [self] emergencyBreak]
+    bind ${:c} <1> [:callback throttle]
+    bind ${:c} <2> [:callback break]
+    bind ${:c} <3> [:callback emergencyBreak]
 
     ${:c} delete all
     ${:c} create rect 32 115 360 125 -fill black ;# frame
@@ -958,7 +961,7 @@
 

Index: doc/example-scripts/tk-locomotive.tcl =================================================================== diff -u -rc2374366bcb47c70ebd33cb16c8152eba783987f -r7c692cef773e19f9da59bef6498ba673cdff468e --- doc/example-scripts/tk-locomotive.tcl (.../tk-locomotive.tcl) (revision c2374366bcb47c70ebd33cb16c8152eba783987f) +++ doc/example-scripts/tk-locomotive.tcl (.../tk-locomotive.tcl) (revision 7c692cef773e19f9da59bef6498ba673cdff468e) @@ -11,6 +11,7 @@ # package require Tk package require nx +package require nx::trait nx::Class create Wheel { :property x @@ -84,6 +85,8 @@ nx::Class create Locomotive { :property {speed 4} + :require trait nx::traits::callback + :method turn {} { set :alpha [expr {round(${:alpha} + 360 - ${:speed}) % 360}] foreach i [${:c} find withtag counterweight] { @@ -145,9 +148,9 @@ set :c [canvas .c -width 600 -height 160 -background lightblue] pack ${:c} - bind ${:c} <1> [list [self] throttle] - bind ${:c} <2> [list [self] break] - bind ${:c} <3> [list [self] emergencyBreak] + bind ${:c} <1> [:callback throttle] + bind ${:c} <2> [:callback break] + bind ${:c} <3> [:callback emergencyBreak] ${:c} delete all ${:c} create rect 32 115 360 125 -fill black ;# frame