Problem with using NSSavePanel's beginSheetForDirectory
Problem with using NSSavePanel's beginSheetForDirectory
- Subject: Problem with using NSSavePanel's beginSheetForDirectory
- From: "Xiaotao Guo" <email@hidden>
- Date: Tue, 11 Mar 2003 16:08:40 -0700
Hi, There:
My program has a floating window called myWindow. I want to use
NSSavePanel's beginSheetForDirectory to pop up a save panel when I try to
close myWindow (like TextEdit). Here is the code in myController.m:
-(void)windowWillClose:(NSNotification *)aNotification
{
[[NSSavePanel savePanel] beginSheetForDirectory:@"~/" file:
@"" modalForWindow:myWindow modalDelegate:self
didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:)
contextInfo:nil];
}
-(void)savePanelDidEnd:(NSSavePanel*)sheet
returnCode:(int)returnCode contextInfo:(void*)contextInfo
{
// handle returnCode
}
The save panel can pop up, and then disappear quickly with myWindow before I
can do anything on it. If I use [NSApp runModalForWindow:savePanel] or
[savePanel runModal] right after beginSheetForDirectory, the save panel
doesn't disappear but myWindow is on top of it.
If I use NSSavePanel's runModalForDirectory:file:relativeToWindow, it works
good. And beginSheetForDirectory works fine if calling it from other
functions, not in windowWillClose.
Any suggestions are really appreciated. Thanks!
X.G
_______________________________________________
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.