Thanks you. That helped a lot, but I'm not done with it..
I'd like to show up the sheet right after the main Window has loaded.
I don't know why, but even though the code seems to be ok, the sheet
does not come up. I also tried to show it with a button just for
testing, but
that also doesn't work.
The according header source:
@interface AppController : NSObject
{
IBOutlet NSWindow *mainMenu;
IBOutlet NSWindow *mySheet;
}
- (IBAction)showSheet: (id)sender;
- (void)showMySheet: (NSWindow *)window;
- (IBAction)closeMySheet: (id)sender;
The according application source:
- (IBAction)showSheet: (id)sender
{
[self showMySheet:mainMenu];
}
- (void)showMySheet: (NSWindow *)window
{
if (!mySheet)
[NSBundle loadNibNamed: @"MySheet" owner: self];
[NSApp beginSheet: mySheet
modalForWindow: window
modalDelegate: nil
didEndSelector: nil
contextInfo: nil];
[NSApp runModalForWindow: mySheet];
[NSApp endSheet: mySheet];
[mySheet orderOut: self];
}
- (IBAction)closeMySheet: (id)sender
{
[NSApp stopModal];
}
When I click on the button, I do only get the following message in
the log:
2006-03-12 17:39:06.328 SheetApp[8019] *** Assertion failure in -
[NSApplication
_commonBeginModalSessionForWindow:relativeToWindow:modalDelegate:didE
ndSelector:contextInfo:], AppKit.subproj/NSApplication.m:3057
2006-03-12 17:39:06.330 Sheet[8019] Modal session requires modal
window
Any idea what I do wrong?
Thanks,
Torsten Trautwein
On Mar 12, 2006, at 11:20 AM, Mike Abdullah wrote:
The problem is how you're actually showing the sheet, you want to
use NSApp's beginSheet method instead.
Mike.