Re: [Fxruby-users] Dialogues, and create.
Status: Inactive
Brought to you by:
lyle
|
From: Lyle J. <jl...@cf...> - 2003-07-02 14:16:29
|
Hugh Sasse Staff Elec Eng wrote:
>> Isn't the create() call propagated from parent to child?
>
> Then why isn't it always? I have found that I have to call create on
> the children before the parent, in the few cases I have done this so
> far.
Hugh,
Sorry for the delayed response. Joel was correct in his response that
when you call create() on a parent window, it recursively calls create()
on all of its child windows that exist at that time. Also, even though
FXApp is not itself a "window", calling FXApp#create will call create()
on all of the top-level windows (e.g. main windows and dialog boxes)
that exist at the time create() is called.
So for the dialog.rb example program, the call to FXApp#create triggers
calls to both DialogTester#create and FXTestDialog#create, since they
are top-level windows and they have been instantiated before the call to
FXApp#create. In turn those calls to DialogTester#create and
FXTestDialog#create trigger recursive calls to create() for all of those
windows' child windows.
> OK, but how do I use this? I mean, I realise my heuristic was
> wrong, because the code works, but how do I revise it to fit with
> reality? :-) Are there whole families of widgets and windows for
> which I can forget about the create() calls? How do I look this
> information up?
I'm trying to think of any exceptions to the rule and I don't know that
there are any. What may be tripping you up, and what frequently throws
people, is that create() only realizes widgets that exist at the time
that create() is called. In other words, say you construct a dialog box:
dialog = FXTestDialog.new(...)
and then create it:
dialog.create
Now if you were to add a new button to the dialog box immediately after
you called FXDialogBox#create:
button = FXButton.new(dialog, ...)
That button doesn't automatically get "created", because it didn't exist
when you previously called create. You must go back and either call
create() on the button itself:
button.create
or, since calls to create() are recursive, you could call create() on
the dialog again:
dialog.create
Calling create() repeatedly on the same object is safe, at least for the
built-in FOX classes. They will still recurse through the list of child
windows, but only actually create the windows that haven't been realized
yet.
Hope this helps,
Lyle
|