I have an application that starts up and as displays its main window on
the screen (this is all automatic as part of loading the nib file, I'm
not doing anything to get this first window on the screen). Once this
main window is fully drawn, I would like to bring up a panel.
If I put the code to bring up the panel in "- (void)awakeFromNib" then
it is drawn *before* the main window, not afterwards as I wanted. So
then I tried to fix this by implementing "-
(void)windowDidUpdate:(NSNotification *)aNotification" so that I can
bring up the panel once I have been notified that the main window has
been updated. The really strange thing is that this didn't work either
- I was still getting the panel before the main window. In desperation
I put in a static variable hack so that my code only brings up the
panel after windowDidUpdate: has been run twice, and then it worked!
So the question is: why did it take two passes through windowDidUpdate:
before the main window was on the screen? And secondly, is there a
better place to put code that should be run after the main window is
fully drawn the first time? (FYI, this is a non-document app).
Thanks in advance.
Chris
Patrick Machielse - 24 Oct 2005 09:30 GMT
> And secondly, is there a better place to put code that should be run after
> the main window is fully drawn the first time? (FYI, this is a
> non-document app).
There is a sequence of predefined 'moments' during the start-up op your
app when you can have code excecuted. awakeFromNib is just one of them
(note that at this point all outlets are connected, but the app nib's
objects are not yet on screen)
You probably want to implement the NSApplication delegate method
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
This method is called just before your app receives its first events.
patrick
Chris Insinger - 24 Oct 2005 21:23 GMT
> You probably want to implement the NSApplication delegate method
>
> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
Well whaddaya know...it works, thanks!
Chris
Simon Slavin - 28 Oct 2005 11:23 GMT
On 24/10/2005, Chris Insinger wrote in message
<2005102413231816807%@news.dslextreme.com>:
> > You probably want to implement the NSApplication delegate method
> >
> > - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
>
> Well whaddaya know...it works, thanks!
Yes. Try to do the bare minimum during awakeFromNib. It's just waking up
and it hasn't had its cup of coffee yet. Better to trigger something from
the window having been updated the first time, or one of the 'Loaded' or
'Finished' methods.
Simon.

Signature
http://www.hearsay.demon.co.uk