Reputation: 47
I have a problem with a sheet that when opened for the first time, will open unattached to the window. After dismissing it, then the sheet works as it should.
Here is the code that I am starting the sheet with:
- (IBAction)addButtonAction:(id)sender {
assert ([editorController window]);
assert (window);
[NSApp beginSheet: [editorController window]
modalForWindow: window
modalDelegate: editorController
didEndSelector: @selector(didEndSheet:returnCode:contextInfo:)
contextInfo: nil];
}
The variables 'window' and 'editorController' are initialized in the application delegate header file as @private.
The 'didEndSelector' is defined in the 'editorController' code file and is called when the window is closed.
The code for the 'didEndSelector' is as follows:
- (void)didEndSheet:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
[sheet orderOut:self];
}
The window is cancelled with a call to selector 'cancelButtonAction' which is as follows:
- (IBAction)cancelButtonAction:(id)sender {
[NSApp endSheet:self.window];
}
Any thoughts would be appreciated.
Upvotes: 0
Views: 127
Reputation: 24145
Make sure the "visible at launch" option on the NSWindow in the xib file isn't turned on.
Upvotes: 1