[fxruby-users] method call question
dwilde1 at gmail.com
Wed Oct 29 06:46:29 EDT 2008
On Mon, Oct 27, 2008 at 12:53 PM, chen li <chen_li3 at yahoo.com> wrote:
> Hi all,
> I am new to FxRuby. I am learning it by studying some code samples. Now I
> am confused about a method call in the following script: which class
> defines method create, class FXApp or HelloWindow/FXMainWindow? Based on
> the code, class HelloWindow/FXMainWindow defines method 'create'. If this is
> true , the object from this class can response to the message. But here why
> does an object created by a different class FXApp response to method
Hello, Li -
Any class can have its own method create. Even Object has several create
methods. In your sample, both HelloWindow and FXApp have methods named
create. If you look at the docs on http://www.fxruby.org/doc/api/, you will
see the method create, but you can't see its source code because it's just a
call to the Fox Toolkit's create in compiled C++ code.
When looking at methods, if you don't see one defined, look to the next
higher class in the inheritance. Sooner or later you'll find one, even if
you have to go all the way up to object. Remember that the name 'create' is
only a symbol referring to the function; it could have been
FXApp::magicalAppPopper() and HelloWindow::magicalWindowpopper.
Also note how HelloWindow makes use of 'super' to get the behavior defined
in FXMainWindow and then add some trimming to it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fxruby-users