123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- //
- // KMMergeSelect.swift
- // PDF Master
- //
- // Created by tangchao on 2023/3/24.
- //
- import Cocoa
- class KMMergeSelect: KMDesignSelect {
-
- private var button: NSButton?
- private var rightButton: NSButton?
- override func viewDidLoad() {
- super.viewDidLoad()
-
- let button = NSButton()
- button.frame = self.view.bounds
- self.view.addSubview(button)
- button.autoresizingMask = [.width, .height]
-
- button.target = self
- button.action = #selector(buttonAction)
- button.wantsLayer = true
- button.isBordered = false
- button.layer?.backgroundColor = NSColor.clear.cgColor
- button.title = ""
- self.button = button
-
- let rightButton = NSButton()
- rightButton.frame = NSMakeRect(NSWidth(self.view.frame)-40, 0, 40, NSHeight(self.view.frame))
- self.view.addSubview(rightButton)
- rightButton.autoresizingMask = [.minXMargin, .height]
-
- rightButton.target = self
- rightButton.action = #selector(buttonAction)
- rightButton.wantsLayer = true
- rightButton.isBordered = false
- rightButton.layer?.backgroundColor = NSColor.clear.cgColor
- rightButton.title = ""
- self.rightButton = rightButton
- }
-
- override var editable: Bool {
- get {
- return super.editable
- }
- set {
- super.editable = newValue
-
- if (self.button != nil) {
- DispatchQueue.main.async {
- self.button?.isHidden = newValue
- }
- }
- }
- }
-
- @objc private func buttonAction() {
- guard let callback = self.mainBox.downCallback else {
- return
- }
- callback(true, self.mainBox, NSEvent())
- }
- }
|