• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How a window was closed?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How a window was closed?


  • Subject: How a window was closed?
  • From: Eric Gorr <email@hidden>
  • Date: Tue, 2 Mar 2010 18:32:25 -0500

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@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How a window was closed?
      • From: Scott Ribe <email@hidden>
    • Re: How a window was closed?
      • From: Jens Alfke <email@hidden>
    • Re: How a window was closed?
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: Re: loadNibNamed:owner [Pilot Error]
  • Next by Date: Re: How a window was closed?
  • Previous by thread: Re: loadNibNamed:owner
  • Next by thread: Re: How a window was closed?
  • Index(es):
    • Date
    • Thread