On Mar 2, 2010, at 6:39 PM, Mike Abdullah wrote: > > On 2 Mar 2010, at 23:32, Eric Gorr wrote: > >> 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]; >> } > > Ack, horrible technique, not a good idea!
I agree, but I needed to try something. So, what is? >> 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? > > What other ways of closing the window are you trying to distinguish it from? Doing so directly with code. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com