• 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 overstaying their welcome
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sheets overstaying their welcome


  • Subject: Re: Sheets overstaying their welcome
  • From: Nick Zitzmann <email@hidden>
  • Date: Wed, 15 Oct 2003 21:33:10 -0700

On Wednesday, October 15, 2003, at 07:48 PM, John Lombardo wrote:

Has anyone encountered the issue of a sheet not automatically retracting
after doing the whole stopModal/endSheet/orderOut routine. Instead, the user
has to interact in some way with the GUI before the sheet retracts. After
some debugging, I've found this happens:

- (void)beginQuerySheet
{
/* ... stuff ... */

[NSApp runModalForWindow:[queryView querySheet]];

// I know that [NSApp stopModal] is being called in another function...
// But this is where we sit until the user clicks something.

[NSApp endSheet:[queryView querySheet]];

[[queryView querySheet] orderOut:self];
}

I suspect you're not using sheets correctly. To begin a sheet, you do this: (note: "someWindow" is an NSWindow)

- (void)beginQuerySheet
{
[NSApp beginSheet:[queryView querySheet] modalForWindow:someWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:nil];
}

Then add something like this to the same class:

- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
// this method gets called when NSApplication's -endSheet:returnCode: is called. do your work here, then, at the end...
[sheet close];
}

You should only call -runModalForWindow: if you want to display a modal window, which is not the same thing as a sheet. Also, make sure that the sheet's backing store is buffered, and "Hide on deactivate" is turned off. HTH...

Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page: http://seiryu.home.comcast.net/

"I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." - Bjarne Stroustrup
_______________________________________________
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.
References: 
 >Sheets overstaying their welcome (From: John Lombardo <email@hidden>)

  • Prev by Date: Re: Compiling AppleScript in Cocoa?
  • Next by Date: Getting printer information
  • Previous by thread: Re: Sheets overstaying their welcome
  • Next by thread: Dictionaries - found it
  • Index(es):
    • Date
    • Thread