Re: NSWindowController that closes itself
Re: NSWindowController that closes itself
- Subject: Re: NSWindowController that closes itself
- From: "Erik M. Buck" <email@hidden>
- Date: Tue, 13 Nov 2001 21:08:42 -0600
>
I'm writing a NSWindowController subclass (but not one to be used for a
>
NSDocument). I've made it the NSWindow delegate for its window as well.
>
>
Now, when the user closes the window, being the NSWindow delegate I get
>
a windowWillClose, and I handle it by sending a message directly to some
>
object and then doing [self autorelease].
>
>
Under certain conditions, I would like to initiate the same process
>
myself, from within my NSWindowController subclass. I tried [[self
>
window] performClose:self], but when I do that, my windowWillClose
>
doesn't get called!
>
>
Why is that, and what should I do to overcome this?
It is probably that way because if you send a message to close the window
you probably want it to close.
However, if you can send -performClose: to a window then you can write the
following code:
if([[[self window] delegate]
respondsToSelector:@selector(windowWillClose:)])
{
if([[[self window] delegate] windowWillClose:[self window]])
{
[[self window] performClose:self];
}
}
else
{
[[self window] performClose:self];
}