From: Josef Wolf Date: 2009-09-12T04:00:13+09:00 Subject: Re: How to bind canvas events to tags? On Sat, Sep 12, 2009 at 02:23:30AM +0900, Joel VanderWerf wrote: > Josef Wolf wrote: >> BTW: do you have a description of the "%x %y" formatting specification? > > http://www.tcl.tk/man/tcl8.4/TkCmd/bind.htm#M41 Ough. Every time I think I get closer (remember? I am trying to implement a zoomable canvas), I find there is a lot more work to do :-() My first attempt to adopt event handling to the zoom operation was like this: class TkEvent::Event # FIXME: need a better name than "nonzoomed". Recommendations? attr_accessor :x_nonzoomed, :y_nonzoomed end class TkZoomCanvas < TkCanvas def itembind(tag, ev, cb) super(tag, ev, proc{ |e| if e.x then e.x_nonzoomed = e.x/@zoom ; end if e.y then e.y_nonzoomed = e.y/@zoom ; end cb.call e }) end def bind(ev, cb) # looks similar to itembind end end Now, itembind (and bind?) seem to accept various forms: 1. canvas.itembind("mytag", "1", proc{|e| ... }) This form works fine with above code 2. canvas.itembind("mytag", "1", "%x %y") {|x, y| ... } In this case, I will have to build the argument list. Seems to be a tedious task. Maybe there already exist a Tk method I could use to build that list? Are this the only two existing forms?