• 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
Re: NSWindow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSWindow


  • Subject: Re: NSWindow
  • From: Shaun Wexler <email@hidden>
  • Date: Sat, 18 Jan 2003 10:05:49 -0800

On Saturday, January 18, 2003, at 09:50 AM, Matis Schotte wrote:

hi,
Which function is called when a window closes? i will bring up a save/dont save dialog when a NSWindow closes by the user ...
thx for answers!! :)
smat

Add this to your program, in the object in which you wish to perform the save/don't save dialog:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowWillClose:) name:NSWindowWillCloseNotification object:window];


- (void) windowWillClose:(NSNotification *)notification
{
NSWindow *windowAboutToClose = [notification object];

if (windowAboutToClose == myWindow)
[NSApp beginSheet:mySavePanel modalForWindow:myWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:) contextInfo:nil];

}

- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowWillCloseNotification object:window];

// handle the returnCode
}
--
Shaun Wexler
MacFOH
http://www.macfoh.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSWindow
      • From: Lachlan Deck <email@hidden>
    • Re: NSWindow
      • From: mw <email@hidden>
References: 
 >NSWindow (From: Matis Schotte <email@hidden>)

  • Prev by Date: Re: NSWindow
  • Next by Date: NSMutableDictionary Error
  • Previous by thread: Re: NSWindow
  • Next by thread: Re: NSWindow
  • Index(es):
    • Date
    • Thread