Reputation: 7350
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
Upvotes: 2
Views: 656
Reputation: 16758
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
Upvotes: 1