Re: Have sheet delay until done?
Re: Have sheet delay until done?
- Subject: Re: Have sheet delay until done?
- From: Carl Harris <email@hidden>
- Date: Wed, 02 Sep 2009 05:51:53 -0400
Chase Meadors wrote:
The problem is, the -runNewItemSheet method is
returning right after starting the sheet. What I want is for it to
wait until the didEnd selector is called to return from the -
runNewItemSheet method. That way, "readyNewItem" will be properly
assigned and not nil.
Is there any way I can accomplish this while still allowing the panel
to work (IBActions etc.) but not return from the original calling
method? I'm drawing a blank here.
This can be accomplished, by running the panel as an application-modal
dialog.
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Sheets/Tasks/UsingAppModalDialogs.html
Using a modal dialog means that the user can't do anything else with
your application until the dialog is dismissed, so you want to avoid
this approach, particularly in a application with multiple independent
windows.
Often, when I find myself wanting to do this sort of thing, it's
because I'm thinking about what the code needs to do sequentially.
Take a step back and think of the UI as providing events that allow
your objects to attain some state, and then decide what actions need
to occur when that state is attained. Take the part that happens in
"someMethod" when the "readyNewItem" property changes state, and
arrange to have that code invoked when the didEndSelector: is
invoked. This will avoid the need for a modal dialog (and its
associated negatives) and will make your code more consistent with the
intended use of the sheet API in Cocoa.
_______________________________________________
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