Re: Single instance of properties window
Re: Single instance of properties window
- Subject: Re: Single instance of properties window
- From: Derrick Bass <email@hidden>
- Date: Mon, 3 Oct 2005 13:17:11 -0700
- Resent-date: Mon, 3 Oct 2005 13:20:10 -0700
- Resent-from: Derrick Bass <email@hidden>
- Resent-message-id: <email@hidden>
- Resent-to: email@hidden
On Oct 3, 2005, at 12:50 PM, email@hidden wrote:
In response to your original post, when you made the window
controller for the window, did you add it to the document's
controller list?
Yes.
I have an app with up to three windows/document, two of which are
only created at need through menu actions. When you close them,
they go away along with their window controllers (-
removeWindowController: is called automagically).
Ahh, I thought about that method, but I didn't notice
removeWindowController, so I couldn't figure out how to get my
windowController pointer set to nil when the window was dismissed.
Anyway, I ended up essentially doing what Sherm suggested off-list,
which was to iterate through the controller array and check to see if
the info window was already open. Since I'm not using custom window
controllers, I looked at the nib name. Here's my code (critique
welcome!):
- (IBAction)showInfo: (id)sender {
NSArray *controllers = [self windowControllers];
NSEnumerator *enumerator = [controllers objectEnumerator];
NSWindowController* controller;
while (controller = [enumerator nextObject])
if ([[controller windowNibName] isEqualTo:@"Properties"])
break;
if (controller == nil) {
controller = [[[NSWindowController alloc]
initWithWindowNibName:@"Properties" owner:self] autorelease];
[controller setShouldCloseDocument:NO];
[self addWindowController: controller];
}
[controller showWindow:self];
}
It seems to working. Thanks for the help!
Derrick
_______________________________________________
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