2

I have a NSSavePanel and I want to handle the "Cancel" button action to prevent closing the sheet. A want to show the confirmation alert above the savePanel sheet like it is done if you want to overwrite file when saving.

What is the best way to implement this?

Thanks

Dmitry
  • 7,300
  • 6
  • 32
  • 55

1 Answers1

1

Some thing like this should work for you-

- (IBAction)showSavePanel:(id)sender
{
    NSSavePanel *mySavePanel = [NSSavePanel savePanel];

    if ([mySavePanel runModal] == NSOKButton) {
        NSLog(@"OK selected");
    }
    else { // cancel button selected
        NSBeginAlertSheet(@"Are you sure", @"Yes", nil, @"No", mySavePanel, self, @selector(sheetDidEndShouldDelete:returnCode:contextInfo:), NULL, sender , @"Your custom message");
    }

}

For additional details you can go through this document - Introduction to Sheets

Devarshi
  • 16,440
  • 13
  • 72
  • 125
  • 1
    In this case the SavePanel has been closed before alert is shown, I don't want to close the save panel... – Dmitry Oct 11 '11 at 12:35