Re: Why would sheet's default button not respond to return key?
Re: Why would sheet's default button not respond to return key?
- Subject: Re: Why would sheet's default button not respond to return key?
- From: Dustin Voss <email@hidden>
- Date: Wed, 28 Aug 2002 22:48:03 -0700
On Tuesday, August 27, 2002, at 10:00 AM, Isaac Sherman wrote:
This code works on my machine:
[NSApp beginSheet:oWindow
modalForWindow:inWindow
modalDelegate:nil
didEndSelector:nil
contextInfo:nil];
[NSApp runModalForWindow:oWindow];
[NSApp endSheet:oWindow];
[oWindow orderOut:self];
And the button is connected to an action which sends:
[NSApp stopModal];
Hang on, now I'm confused. Wouldn't make the sheet application-modal
rather than document-modal? The description of "runModalForWindow:"
says that all events will be ignored except for ones involving the
specified window. That would mean that other open document windows
would be non-responsive. This is not what sheets are intended to do;
they make only one window non-responsive: their document window.
I'm writing a preference pane that can display an "About" sheet. The
sheet has its own controller, which implements the sheet's opening and
closing. Here's the relevant controller code:
------------------------8<----------------------
- (id) init
{
BOOL couldLoad;
[super init];
couldLoad = [NSBundle loadNibNamed:@"About" owner:self];
return (couldLoad ? self : nil);
}
- (void) openPanel
{
[NSApp beginSheet:panel modalForWindow:[NSApp mainWindow]
modalDelegate:nil didEndSelector:nil contextInfo:nil];
}
- (void)closePanel:(id)sender
{
[panel close];
[NSApp endSheet:panel];
}
----------------------8<-------------------------
Earlier in this thread, I said I connected the OK button to
"performClose:". I was, in fact, wrong about that. Here's how I really
hooked it up:
In the NIB, the panel is connected to the "panel" outlet and the OK
button is connected to "closePanel:" action. The main window controller
calls "openPanel" to display the sheet.
I don't use "runModalForWindow:", "orderOut:", or "stopModal:", but
everything seems to work fine. I would say that if you are trying to
make a document-modal sheet, this is the way to do it. Am I wrong? If
so, why? I want to make sure I haven't missed anything.
(Actually, I know I am least partially wrong, because I'm not sure how
to display another sheet. I should temporarily close this one to
display the other, then bring this one back.)
--
Dustin
_______________________________________________
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.