# Draggable Text Tclet
# Adapted from the example on the SunLabs web site
# http://www.sunlabs.com/research/tcl/plugin/applets.html
#
proc dragstart {w x y} {
    global draglocation
    catch {unset draglocation}
    set draglocation(obj) [$w find closest $x $y]
    set draglocation(x) $x
    set draglocation(y) $y
}
proc dragit {w x y} {
    global draglocation
    if {"$draglocation(obj)" != ""} {
        set dx [expr $x - $draglocation(x)]
        set dy [expr $y - $draglocation(y)]
        $w move $draglocation(obj) $dx $dy
        set draglocation(x) $x
        set draglocation(y) $y
    }
}
canvas .c -bg $embed_args(background) \
                -width $embed_args(width) -height $embed_args(height)
.c create text 80 50 -text $embed_args(text1) \
                -font *-times-bold-r-*-24-* \
           -tags {movable color=red} -fill $embed_args(color1)
.c create text 200 100 -text $embed_args(text2) \
                -font *-times-medium-i-*-24-* \
           -tags {movable color=blue} -fill $embed_args(color2)
.c bind movable <Button-1> {dragstart %W %x %y}
.c bind movable <B1-Motion> {dragit %W %x %y}
pack .c