Re: Single instance of properties window
Re: Single instance of properties window
- Subject: Re: Single instance of properties window
- From: email@hidden
- Date: Mon, 3 Oct 2005 14:50:11 -0500
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?
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).
See the following code:
- (void)makeWindowControllers
{
windowController = [[MyDocumentWindowController alloc]
initWithOwner: self];
[self addWindowController: windowController];
}
- (IBAction)makeSummaryWindow:(id)sender
{
if ( !summaryController ) {
summaryController = [[MySummaryWindowController alloc] init];
[self addWindowController: summaryController];
}
[summaryController showWindow: self];
}
- (IBAction)makeMonitorWindow:(id)sender
{
if ( !monitorController ) {
monitorController = [[MyMonitorWindowController alloc]
initWithMonitor: monitor];
[self addWindowController: monitorController];
}
[monitorController showWindow: self];
}
- (void)removeWindowController:(NSWindowController *)aController
{
if ( aController == summaryController ) {
[summaryController release];
summaryController = nil;
}
if ( aController == monitorController ) {
[monitorController release];
monitorController = nil;
}
if ( aController == windowController ) {
[windowController release];
windowController = nil;
}
[super removeWindowController: aController];
}
On Oct 3, 2005, at 2:03 PM, Derrick Bass wrote:
Date: Mon, 3 Oct 2005 12:59:25 -0500
From: Derrick Bass <email@hidden>
Subject: Re: Single instance of properties window
On Oct 3, 2005, at 12:49 PM, Sherm Pendley wrote:
Create an NSWindowController subclass that has a class method to
return a shared instance:
+ (id) sharedPropertiesController {
static MyPropertiesController *controller;
if (nil == controller) {
controller = [[MyPropertiesController alloc]
initWithWindowNibName:@"Properties" owner:self];
}
return controller;
}
Note that this controller, since it's shared instead of being
associated with a single document, should *not* be owned by an
NSDocument instance. In your document class, you'd do something
like this to show it:
[[MyPropertiesController sharedPropertiesController]
showWindow:self];
But wouldn't that mean I'd have only one properties window for the
entire app? That's not what I'm after. I want the user to be able
to open one properties window for each document. (Like the
QuickTime Player 7 Properties window.)
_______________________________________________
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