12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- //
- // KMToolbarCustomWindowController.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2023/10/26.
- //
- import Cocoa
- class KMToolbarCustomWindowController: NSWindowController {
- weak var toolbar: KMToolbarView?
- var toolbarCustomViewController: KMToolbarCustomViewController?
-
- var resetCallback: KMEmptyBlock?
-
- deinit {
- Swift.debugPrint("KMToolbarCustomWindowController deinit")
- }
-
- convenience init() {
- self.init(windowNibName: "KMToolbarCustomWindowController")
- }
-
- override func windowDidLoad() {
- super.windowDidLoad()
-
- self.toolbarCustomViewController = KMToolbarCustomViewController()
- self.toolbarCustomViewController?.toolbar = self.toolbar
- if self.responds(to: NSSelectorFromString("setContentViewController:")) {
- self.contentViewController = self.toolbarCustomViewController
- } else {
- self.toolbarCustomViewController?.view.frame = self.window?.contentView?.bounds ?? .zero
- if let sview = self.toolbarCustomViewController?.view {
- self.window?.contentView?.addSubview(sview)
- }
- }
-
- self.toolbarCustomViewController?.itemClick = { [weak self] idx, _ in
- if idx == 0 { // cancel
- self?.km_quick_endSheet(.cancel)
- } else if idx == 1 { // ok
- self?.km_quick_endSheet(.OK)
- } else if idx == 2 { // reset
- self?.resetCallback?()
- }
- }
- }
- }
|