From: David Bailey Date: 2006-04-01T23:14:59+09:00 Subject: Re: Ruby/Tk (X,Y) Coordinate Question Chris Alfeld wrote: > Actually, what I think you are looking for is the translation from > "real" coordinates to canvas coordinates for which you want: > > canvas.canvasx and canvas.canvasy > > also note that you can bind mouse clicks to Tkc objects, though be > careful that if the fill is none then TkcRect's won't register clicks > on the interior. > > So, in summary, see TkCanvas.canvasx, TkCanvas.canvasy, and > TkcRectangle.bind > (actually part of the TkcTagAccess mixin). > > Another command you may find useful is TkCanvas.find_overlapping which > can translate a mouse click to a TkcObject. Thus code such as: > > obj_at_xy = > @canvas.find_overlapping(@canvas.canvasx(x),@canvas.canvasy(y), > @canvas.canvasx(x),@canvas.canvasy(y)) > > Here I believe x,y should be from %x,%y, that is, relative to the canvas > widget. > > c. Chris, I'm researching these canvasx and canvasy methods now. I'll let you know how I make out. Thank you for your help. David -- Posted via http://www.ruby-forum.com/.