I am using (NSPrintOperation *)printOperationWithView:(NSView *)aView printInfo:(NSPrintInfo *)aPrintInfo method to print a view in my OS X app. All works as expected. Is there a way to catch the event when the user has cancelled the print operation by clicking on the "cancel" button on the print panel? I have been searching here, Apple's printing programming guide and the web but found nothing so far. Does anyone know how?
Solved it! I added a selector to print operation method to catch the event when the printPanelDidEnd:
[printOp runOperationModalForWindow:myWindow delegate:self didRunSelector:@selector(printPanelDidEnd:returnCode:contextInfo:) contextInfo:nil];
and then:
- (void)printPanelDidEnd:(NSPrintPanel *)printPanel returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo {
if (returnCode == NSCancelButton) {
NSLog(@"Cancel button was selected");
}
}