Is there any way to determine how a window was closed?

I need to base what I do on whether or not a window will be closed by the user 
pressing the close (red) button or some other way.

One thing I did try was:

                        NSButton *closeButton = [[self window] 
standardWindowButton:NSWindowCloseButton];
                
                        fCloseButtonTarget      = [[closeButton target] retain];
                        fCloseButtonAction      = [closeButton action];
                        
                        [closeButton setTarget:self];
                        [closeButton setAction:@selector(closeInterceptor:)];

basically, got the close button and attempted to insert my own close action 
selector which was implemented as:

- (void) closeInterceptor:(id)sender
{
        // my stuff here

        [NSApp sendAction:fCloseButtonAction to:fCloseButtonTarget 
from:sender]; 
}


However, this did not seem to work as I might have expected. My window 
controller no longer receives the window will close notification, for example.

Any other thoughts?

Thank you.


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to