avoiding to open window multiple times
avoiding to open window multiple times
- Subject: avoiding to open window multiple times
- From: "Joris Mans" <email@hidden>
- Date: Sun, 19 Feb 2006 17:16:42 +0100
Hello,
I have multiple nib files in my application, one for each kind of data i
want to edit in an assoc.d window. (e.g. 1 nib file containing instances and
the window to edit an addressbook, etc) as explained in the Apple docs. Now
I want to make sure that when a user opens a window through the menu, and
the window exists already, that the app doesnt instance the window a second
time.
I load and show the window using an NSWindowController using
iniWithWindowNibName.
I add the controller to a list in my object and add a notification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowClosed:) name:NSWindowWillCloseNotification
object:[window_controller window]];
When initing the window using the controller, i take the NSMenuItem which
caused the action, and remove its target by setTarget:nil so it effectively
gets greyed out and unusable.
When the close notification is received i put the target back so the user
can click on it again to reopen the window.
Is this a good way of handling this? Isnt there a better way?
Joris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden