From: Phlip Date: 2004-08-15T10:46:05+09:00 Subject: Fake Tk events Rubies: I posted a fix for this a while ago, and then tk.rb upgraded. The quest is to build a fake event and send it into a bound event handler. This code creates a canvas, writes "hello world" on it, and fakes a 'Button-1' click on that text: require 'tk' top = TkRoot.new() canvas = TkCanvas.new(top) {width(400);height(300) } canvas.grid() tx = TkcText.new(canvas, 100, 200) { text 'hello world' } tx.bind('Button-1') { |e| p e.x p e.y } entry = tx.bindinfo('Button-1')[0][0] entry.call( 21, "??", 1, 0, "??", true, 0, "i", 1, "NotifyNormal", false, "PlaceOnTop", 0, 7595922, 0, 115, 200, "??", 269, 1, false, "??", 1, "0x0", "0x0", 4, nil, 269, 376 ) Tk.mainloop() It faults, emitting this error message: c:/ruby/lib/ruby/1.8/tk/event.rb:167:in `num_or_str': wrong argument type Fixnum (expected String) (TypeError) from c:/ruby/lib/ruby/1.8/tk/event.rb:167:in `call' from c:/ruby/lib/ruby/1.8/tk/event.rb:167:in `scan_args' from c:/ruby/lib/ruby/1.8/tk/event.rb:167:in `install_bind_for_event_class' from c:/ruby/lib/ruby/1.8/tk/event.rb:163:in `call' from c:/ruby/lib/ruby/1.8/tk.rb:1039:in `eval_cmd' from c:/ruby/lib/ruby/1.8/tk.rb:1039:in `cb_eval' from c:/ruby/lib/ruby/1.8/tk.rb:990:in `call' from yo.rb:16 That error message does not describe which argument is amiss, or if there are too many or too few. I have painstakingly matched the arguments to KEY_TBL in event.rb. How do I diagnose such error messages? And how do I fake events -- Phlip http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces