Re: Sheets
Re: Sheets
- Subject: Re: Sheets
- From: Steve Klingsporn <email@hidden>
- Date: Tue, 5 Nov 2002 12:48:18 -0600
Nope, not really. This is a misconception. The modal stuff is not
necessary. It cost me hours of my life, until I read an article by
some lady at Apple off cocoa.mamasam.com that set me straight.
Here's some code that works for me.
NSApplication.sharedApplication().beginSheet(
requestPanel, mGameWindow, this,
new NSSelector("requestSheetDidEnd",
new Class[] {
NSWindow.class,
Integer.class,
Object.class }), null);
public void requestSheetDidEnd(NSWindow window,
int result,
Object contextInfo)
{
/* Do something here. */
closeAnySheet(null);
}
...and:
public void closeAnySheet(Object sender)
{
NSWindow sheet = mGameWindow.attachedSheet();
if (sheet != null)
{
sheet.orderOut(null);
NSApplication.sharedApplication().endSheet(sheet);
}
}
Excuse the Java <grin/>
I used the "closeAnySheet" method because there are situations in which
I'm going to close a sheet, and don't know which one I want to close.
You can just call "orderOut()" and "endSheet()" using a reference to
the sheet if you know what it is, else you can get it from the window
via "attachedSheet()".
Steve
On Tuesday, November 5, 2002, at 11:36 AM,
email@hidden wrote:
>
I believe you need to call two other NSApp functions as well -
>
runModalForWindow and stopModal.. I use the code
>
below to end sheet display, and I haven't seen this problem.
>
>
--- showing the sheet:
>
[NSApp beginSheet:aWindow
>
modalForWindow:aHostWindow
>
modalDelegate:nil
>
didEndSelector:nil
>
contextInfo:nil];
>
[NSApp runModalForWindow:aWindow];
>
>
--- hiding the sheet:
>
[NSApp endSheet:aWindow];
>
[aWindow orderOut: self];
>
[NSApp stopModal];
>
>
Perhaps that will fix it.
>
- Chris Corbell
_______________________________________________
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.