Application modal sheets
Application modal sheets
- Subject: Application modal sheets
- From: "Paul J. Lucas" <email@hidden>
- Date: Fri, 21 Oct 2005 17:22:33 -0700 (PDT)
If I've got a one-window-only application, then a sheet (ordinarily a
window-modal "dialog") becomes an application modal dialog.
That being the case, it would be nice to have the caller block until
the sheet is dismissed. If I derive aclass from NSAlert, say,
ModalAlertSheet, and add the methods:
- (int) showAttachedToWindow:
(NSWindow*)window
{
[self
beginSheetModalForWindow:window
modalDelegate:self
didEndSelector:@selector(alertEnded:returnCode:contextInfo:)
contextInfo:nil
];
return [NSApp runModalForWindow:[self window]];
}
- (void) alertEnded:
(NSAlert*)alert
returnCode:(int)returnCode
contextInfo:(void*)contextInfo
{
[[alert window] orderOut:self];
[NSApp stopModalWithCode:returnCode];
}
and call it like:
ModalAlertSheet *alert = [[ModalAlertSheet] alloc] init];
// ...
int button = [alert showAttachedToWindow:mainWindow]
then: is this an OK thing to do? It seems to work just fine.
- Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden