How to bring back a window

I have a very simple ASOC project that has one window. If the user clicks the red close button on accident, they will have to quit the program entirely and then re-launch it to make the window re-appear. I’ve looked through IB but I’m not seeing anywhere that will bring the window back if the user clicks the logo in the dock (which is what I would like to happen.) I would try to use the documentation, but I don’t even know what to call what I’m trying to do! :o

Any help would be appreciated! And sorry for the noob question!

Hi,

implement the applicationDidBecomeActive: delegate method.
In this method check whether the window exists. If it does not open it

I thought the delegate method was NSApplication’s applicationOpenUntitledFile:?

The behavior of document based applications and non-document based applications is different.
The latter will do nothing after calling applicationOpenUntitledFile

I tested it to be certain, and I’m sorry to say that what you say is not true, at least it isn’t in Leopard. applicationDidBecomeActive: did only get called on launch, applicationOpenUntitledFile: did however get called every time the dock-icon was clicked and no window was visible. Maybe this behavior is different in Snow Leopard, but I hardly doubt it.

Chrissy,

Have you considered just disabling the close button, and perhaps enabling Hide on Deactivate?

Indeed you’re right, applicationOpenUntitledFile: will be called every time the dock icon is clicked but in an non-document based app the main window won’t be opened.
applicationDidBecomeActive: will be called every time the app becomes frontmost for instance when you press twice ⌘⇥

Thanks for everyones help, but I used Shane’s suggestion. It works just like I was hoping it to! I appreciate it!