My goal: to display my own sheet with a specific NSProgressIndicator, while the application runs through a long cycle. I want the sheet to be applied, not document-modal. User cannot reject modal sheet. They must wait for the application to complete the loop processing.
Problem: I cannot connect a user sheet to the window. It is displayed as a separate window, in which there is no window title bar (in the form of a sheet). In addition, the sheet does not release (does not close) when the loop ends.
I have 2 separate nib files for the sheet and the main application window, as well as 2 controller classes for each window.
Here's the pertinent information: Implementing a controller for a user sheet:
@implementation ProgressSheetController //subclass of NSPanel -(void)showProgressSheet:(NSWindow *)window { //progressPanel is an IBOutlet to the NSPanel if(!progressPanel) [NSBundle loadNibNamed:@"ProgressPanel" owner:self]; [NSApp beginSheet: progressPanel modalForWindow: window modalDelegate: nil didEndSelector: nil contextInfo: nil]; //modalSession is an instance variable modalSession = [NSApp beginModalSessionForWindow:progressPanel]; [NSApp runModalSession:modalSession]; } -(void)removeProgressSheet { [NSApp endModalSession:modalSession]; [NSApp endSheet:progressPanel]; [progressPanel orderOut:nil]; } //some other methods @end
Implementation for the main application window. The testFiles method is an IBAction connected to the button.
@implementation MainWindowViewController //subclass of NSObject -(IBAction)testFiles:(id)sender; {
One thought: am I subclassing correctly? Should I use NSWindowController? Thank you in advance for your help!
source share