我正在使用 (NSPrintOperation *)printOperationWithView:(NSView *)aView printInfo:(NSPrintInfo *)aPrintInfo 方法在我的 OS X 应用程序中打印视图。一切都按预期工作。当用户通过单击打印面板上的“取消”按钮取消打印操作时,有没有办法捕捉事件?我一直在这里搜索 Apple 的打印编程指南和网络,但到目前为止一无所获。有谁知道怎么做?
问问题
311 次
1 回答
0
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");
}
}
于 2014-11-09T22:54:31.180 回答