• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sheets
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: [Newbie Q] Memory Management in Cocoa
  • Next by Date: Re: [Newbie Q] Memory Management in Cocoa
  • Previous by thread: White background for modal Dialogs/Panels
  • Next by thread: [newbie] sending PDF to printer
  • Index(es):
    • Date
    • Thread