1

How do you show a NSWindow from the toolbar, like the NSOpenPanel in the picture below?

enter image description here

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
hpique
  • 119,096
  • 131
  • 338
  • 476

1 Answers1

5

Uncheck Visible At Launch from the window properties in the NIB file and then use beginSheet:

[NSApp beginSheet:sheetWindow
           modalForWindow:mainWindow
           modalDelegate:self
           didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
           contextInfo:NULL];

Additionally, NSSavePanel provides beginSheetModalForWindow as a convenience method:

[savePanel beginSheetModalForWindow:mainWindow completionHandler:^(NSInteger result) {
    if (result != NSFileHandlingPanelOKButton) return;
    // Do something
}];
hpique
  • 119,096
  • 131
  • 338
  • 476