#!/bin/sh
#\
exec wish8.3 $0 $* &
#\
exit
#
# Show the bug
#

pack [label .x -textvariable X]
pack [label .y -textvariable Y]
pack [frame .fr] -expand 1 -fill both
pack [scrollbar .fr.vsc -command ".c yview" -orient vertical -takefocus 0] -side left -fill y -anc nw
pack [scrollbar .fr.hsc -command ".c xview"  -orient horizontal -takefocus 0] -side bottom -fill x -anc nw
pack [canvas .c -yscrollcommand ".fr.vsc set" -xscrollcommand ".fr.hsc set"] \
	-in .fr -expand 1 -fill both

pack [label .l -text "This is a lable on the same window"]
set id [.c create text 0 0 -text "Hello"]
.c create line -100 0 100 0 -tag CursorX
.c create line 0 -100 0 100 -tag CursorX
.c create line 0 0 0 0 -tag "Cursor CursorX"

	event add	<<MOTION>>	<Motion>
	event add	<<SHIFT-MOTION>>	<Shift-Motion>

	foreach ve {SELECT END SHIFT-MOTION MOTION CANCEL EXTEND ADJUST HELP} {
		bind .c <<$ve>> "genEvent name <$ve> %K %A %x %y %W ; break"
	}


proc genEvent {name event K A x y win} {
	global X
	global Y
	global id
	set X $x
	set Y $y 
#	 .c coords  $id  $x $y
	canvasMoveCursor .c $x $y
}


proc canvasMoveCursor { c x y} { 

	set rx [$c canvasx $x]
	set ry [$c canvasy $y]
	set x1 [$c canvasx 0]
	set y1 [$c canvasy 0]
	set w [winfo width $c]
	set h [winfo height $c]

	set cx 0
	set cy 0
	scan [$c coords Cursor] "%f %f" cx cy
	$c move CursorX [expr $rx - $cx ] [expr $ry - $cy]
#	scan [$c coords CursorH] "%f %f" cx cy
#	$c move CursorH [expr $x1 - $cx ] [expr $ry - $cy ]

}


