Re: Re: Special requirements for the window param of NSAlert beginSheetModalForWindow?
Re: Re: Special requirements for the window param of NSAlert beginSheetModalForWindow?
- Subject: Re: Re: Special requirements for the window param of NSAlert beginSheetModalForWindow?
- From: Michael Ash <email@hidden>
- Date: Wed, 13 May 2009 23:07:26 -0400
On Wed, May 13, 2009 at 9:10 AM, Dennis Christopher
<email@hidden> wrote:
> On this subject, I am having difficulty putting up a second modal sheet
> (alert) for the same window. I call beginSheetModalForWindow in the didEnd
> selector of the first alert, if you follow my meaning. It seems I get some
> kind of unexpected behaviour doing this, including the floating alert case.
> Or the secondary alert appearing twice. I guess I dont understand what
> counts as the first sheet being dismissed. I would have thought that the
> didEnd selector being called was sufficient??
The name is a bit misleading. If you put a breakpoint in this method
and look at your app while the debugger is paused there, you'll notice
that the sheet is still present. This is why trying to add a new sheet
doesn't work.
There are three ways to work around this:
1) Avoid displaying a new window of any kind. This is best, if it can
fit with your workflow. It's generally bad UI to go from one modal
window to another. This can't always be done reasonably, but if you
can do something else like display an extra pane of the existing
window, it can be better.
2) Display the second window as a modal panel instead of a sheet.
Apple does this with NSSavePanel if you try to save over an existing
file. It's easy and works well, but of course the modal panel blocks
your entire application while it's being displayed.
3) Use performSelector:withObject:afterDelay: with a 0 delay to run
the code to show the new sheet after the old sheet has truly gone
away. This will result in one sheet being followed by another sheet as
you desire.
Mike
_______________________________________________
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