How to get my job properly in NSPrintPanel?

31 views Asked by At

I want to get which button I clicked in NSPrintPanel. I find NSPrintInfo.shared.jobDisposition shows the operation.

extension NSPrintInfo.JobDisposition {
    
    public static let spool: NSPrintInfo.JobDisposition

    public static let preview: NSPrintInfo.JobDisposition

    public static let save: NSPrintInfo.JobDisposition

    public static let cancel: NSPrintInfo.JobDisposition
}

So I do this:

let printOperation = NSPrintOperation(view: view, printInfo: printInfo)
printOperation.showsPrintPanel = true
printOpeartion.run()

In the displayed NSPrintPanel, all buttons are normal, but no matter which button I click, the value of NSPrintInfo.shared.jobDisposition is always · .spool.

If I use a custom NSPrintPanel, all buttons are invalid, but the value of NSPrintInfo.shared.jobDisposition is normal (for example, when the preview button is clicked, the value is .preview).

let printPanel = NSPrintPanel()
let result = printPanel.runModal(with: printInfo)

So, how to make the custom NSPrintPanel behave properly? How to get my job properly in NSPrintPanel? Thanks!

0

There are 0 answers