Hidetoshi NAGAI wrote: > From: David Bailey <david.bailey / technologist.com> > Subject: Re: Ruby/Tk (X,Y) Coordinate Question > Date: Sat, 1 Apr 2006 23:12:00 +0900 > Message-ID: <13a738b2f770dc0de16ca015e13045ce / ruby-forum.com> >> Um, just to try out these %X and %Y objects real quick, I added X, Y, %X >> and %Y to my argument list in the callback proc in the same form as the >> x, y, %x and %y objects to see what would happen, but got the following >> "dynamic constant assignment" and "formal argument" errors: > > X and Y are constans. You must use local variables. > e.g. > @root.bind('Button', > proc{|b,x,y,root_x,root_y| > mainCellClickedProc(b, x, y, root_x, root_y) > }, "%b %x %y %X %Y") Hidetoshi, At first I jumped with joy thinking that root_x and root_y would solve my problem. Uh, it still may, but ... When I bind via this: @root.bind('Button', proc{|b,x,y,root_x,root_y| \ mainCellClickedProc(b, x, y,root_x,root_y)}, "%b %x %y %X %Y") And report the mouse-click coordinates with this method: def tell_it(btn, x, y,root_x, root_y) puts "tell_it: Mouse button #{btn} clicked at coordinates (#{x},#{y})" +\ " and (#{root_x},#{root_y}))" end The root_x and root_y coordinates are relative to the top left corner of the "screen". For example, here is the output of a mouse-click on the top left corner of my application: tell_it: Mouse button 1 clicked at coordinates (2,1) and (278,32)) Now, if I move the application window on the Windows XP screen and click in the same relative position of the application's window, here is the output of that mouse-click: tell_it: Mouse button 1 clicked at coordinates (2,1) and (153,80)) See? The (x,y) coordinates are the same, but the (root_x,root_y) coordinates have changed to reflect that the application's window has moved on the Windows XP Desktop. I was hoping that "both" (x,y) and (root_x,root_y) would be the same, but they are not. You know, when I use the "place" geometry manager, the :x and :y objects are relative to the "parent" widget's origin, but the "event" :x and :y objects seem to be relative to the "self" widget's origin. Do you agree? In any case, it appears that I'm back to "square one", so to speak. -- Posted via http://www.ruby-forum.com/.