From: Phlip Date: 2004-08-22T05:15:47+09:00 Subject: Re: Fake Tk events Hidetoshi NAGAI wrote: > Probably, to generate events on canvas items, the canvas requires > to know the mouse position by 'Enter' or 'Motion' event. BTW I keep lecturing about clean code, and using Ruby driving TkCanvas as a sterling example... ....and I just peeked inside tkCanvas.c, and it is a bucket of shit. One of these functions is 1400 lines long! Compilers should just refuse to go over 99; they'd probably run faster on that internal optimization. > Please try to add one line to your script such as the following. > > > def click(what, how = 'Button-1') > > x1,y1,x2,y2 = what.bbox > > cx = (x2 + x1) / 2 > > cy = (y2 - y1) / 2 > > Tk.update() > > what.event_generate('Motion', :x => cx, :y => cy) > > what.event_generate(how, :x => cx, :y => cy) > > end Noop. It no worky. Don't sweat this - nobody pushes libraries where I push them. Thanks again for the help. I'm going with this: def click(what, how = 'Button-1') cb_entry = what.bindinfo(how)[0][0] cb_entry.call() end One deciding factor is the code may come to use x or y, and you showed how to slip them in without risking friction at library upgrade time. -- Phlip http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces