Re: Modal Alert Sheet
Re: Modal Alert Sheet
On 5 Oct 2013, at 12:28, Jim Elliott <email@hidden> wrote:
> An odd thing is happening when I invoke the NSAlert method beginSheetModelForWindow:modalDelegate:didEndSelector:conextInfo. It seems that the method returns before calling and returning from the didEndSelector.
>
This is not odd, its expected. This method returns immediately unlike NSApplication -runModalForWindow which sets up a modal event loop.
The sheet is modal for the window only. If it blocked the run loop then no events would be delivered to any other window.
> To be more specific, I have subclassed the NSDocument method canCloseDocument: because I have some additional cleanup to do before the document window goes away. If the cleanup is needed, I create an alert sheet and asks the user if he wants the cleanup performed. After calling beginSheetModalWithWindow, I then invoke canCloseDocument on super.
>
I would do something like set a document level cleanupDone flag.
If cleanupDone is NO then show the sheet and return NO in -canCloseDocument.
In the didEndSelector method test if cleanup was successful. If so set the flag to YES and close the document again.
- canCloseDocument can now return YES based on the flag status.
HTH
Jonathan
_______________________________________________
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