Closing windows bearing sheets
Closing windows bearing sheets
- Subject: Closing windows bearing sheets
- From: Dan Bernstein <email@hidden>
- Date: Fri, 1 Mar 2002 18:25:08 +0200
I have a NSWindowController that sometimes displays a sheet attached to
its window. While the close widget and the close menu command are
disabled for that window when it's displaying the sheet, it can still
receive a close: message if, for example, the user option-closes another
window belonging to the same app. This makes my window close as well,
taking the sheet with it. However, NSApp never receives the endSheet:
for that sheet, so subsequently the user can't quit the application.
You can see what I mean by opening TextEdit, creating 2 new documents,
choosing Page Setup for one of them and option-clicking the close widget
of the other. This will close the 2 windows, including the one which was
displaying the Page Setup sheet. Trying to quit TextEdit now wouldn't
work.
This is a bug, of course, and I'm trying to avoid it in my application.
So far my best solution is making the NSWindowController the delegate
for its window and in its windowWillClose: method to say
if ([[self window] attachedSheet])
[NSApp endSheet:[[self window] attachedSheet]];
but then I have to be very careful about what I put in my
sheetDidEnd:returnCode:contextInfo: for that sheet. In particular, I
have to avoid orderOut:ing it, to avoid the sheet effect in the above
situation.
Is there anything better that I could do?
TIA,
-- Dan Bernstein
_______________________________________________
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.