Updated 2014-05-08 16:42:25 by brusch

There are 2 problems when looking for items at a given position:

  • On mouse click, you get window coordinates, but you need canvas coordinates for "find".
  • Canvas find returns only the ID of the item, that's a plain number. You will need to retrieve the parameters of the item by further functions.

canvas .c1
bind .c1 <Double-1> { onDblClick %x %y }
proc onDblClick {x y} {
        set x [.c1 canvasx $x] ; set y [.c1 canvasy $y]
        set i [.c1 find closest $x $y]
        set t [.c1 gettags $i]
        puts "$i $t"