From: Robert Klemme Date: 2008-10-28T02:59:36+09:00 Subject: Re: question about method call On 27.10.2008 18:32, Li Chen wrote: > Robert Klemme wrote: >> Read your code again. >> >>> receive a message defined by class by HelloWindow (or >>> FXMainWindow) and response it? >> You probably need more coffee - or more sleep. :-) > > > Reading from the codes it looks app receive a message from > FXApp.new, which I have no problem to understand that. But if I remove > "create" defined by class HelloWindow(or FXMainWindow) the script > won't work. This is why I am confused. You are right: I am the one who needs more coffee or sleep. :-} I do not know Fox but I would guess that the FXMainWindow#initialize registers with FXApp instance and that in turn sends messages it does not understand to the main window instance. Not difficult to do: irb(main):001:0> class App irb(main):002:1> def register(obj) irb(main):003:2> @delegat = obj irb(main):004:2> end irb(main):005:1> def method_missing(*a,&b) irb(main):006:2> @delegat ? @delegat.send(*a,&b) : super irb(main):007:2> end irb(main):008:1> end => nil irb(main):009:0> class Win irb(main):010:1> def initialize(app) app.register(self) end irb(main):011:1> def boo() puts "boo!" end irb(main):012:1> end => nil irb(main):013:0> a = App.new => # irb(main):014:0> w = Win.new a => # irb(main):015:0> a.boo boo! => nil irb(main):016:0> Cheers robert