canvashelp

set text {Richard Suchenwirth 2004-05-08 - I thought of adding a help text to the canvas in Tangram in a minimal way and came up with this idea: A text item on the canvas changes on clicking to the help text, and back again. A single proc does all the work. }

 proc canvashelp {w label text x {y ""}} {
    if {$y ne ""} { #-- "constructor" if called with coordinates
        set id [$w create text $x $y -text $label -anchor nw]
        $w bind $id <1> [list canvashelp $w $label $text $id]
    } else { #-- binding "callback" if called with a canvas id
        set id $x
        if {[$w itemcget $id -text] ne $label} {set text $label}
        $w itemconfigure $id -text $text
    }
 }

#-- Testing:

 if {[file tail [info script]] eq [file tail $argv0]} {
    pack [canvas .c]
    canvashelp .c ? $text 5 5
    bind . <Escape> {exec wish $argv0 &; exit}
 }