#--------------------------------------------------
# A demo application using the canvas widget. The 
# user can move the text with the mouse. This demo is
# included in the standard release of Tcl/Tk
#--------------------------------------------------
 



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
    }
}

#--------------------------------------------------
# Create the canvas and text
#--------------------------------------------------

canvas .c -bg bisque -width 400 -height 400
.c create text 50 50 -text Hello \
		-font *-times-bold-r-*-18-* \
		-tags {movable color=red} -fill red
.c create text 100 100 -text World \
		-font *-times-medium-i-*-18-* \
		-tags {movable color=blue} -fill blue
.c bind movable  {dragstart %W %x %y}
.c bind movable  {dragit %W %x %y}
pack .c