CDSignatureTextViewController.swift 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // CDSignatureTextViewController.swift
  3. // PDF Reader Pro Edition
  4. //
  5. // Created by Niehaoyu on 2023/10/16.
  6. //
  7. import Cocoa
  8. class CDSignatureTextViewController: NSViewController {
  9. @IBOutlet weak var signTextField: NSTextField!
  10. @IBOutlet weak var cancelButton: NSButton!
  11. @IBOutlet weak var applyButton: NSButton!
  12. @IBOutlet weak var clearButton: NSButton!
  13. var drawText: String!
  14. var actionBlock: ((_ textVC: CDSignatureTextViewController, _ inputText: String)->Void)?
  15. override func viewDidAppear() {
  16. super.viewDidAppear()
  17. self.view.window?.title = "";
  18. // self.view.window?.styleMask = [self.view.window?.styleMask, .fullSizeContentView]
  19. self.view.window?.titlebarAppearsTransparent = true
  20. self.view.window?.backgroundColor = NSColor(red: 252.0/255.0, green: 253.0/255.0, blue: 255.0/255.0, alpha: 1.0)
  21. self.view.window?.standardWindowButton(.closeButton)?.isHidden = true
  22. self.view.window?.standardWindowButton(.miniaturizeButton)?.isHidden = true
  23. self.view.window?.standardWindowButton(.zoomButton)?.isHidden = true
  24. self.signTextField.textColor = NSColor.labelColor
  25. self.signTextField.stringValue = self.drawText! as String
  26. }
  27. override func viewDidLoad() {
  28. super.viewDidLoad()
  29. // Do view setup here.
  30. self.cancelButton.title = NSLocalizedString("Cancel", comment: "")
  31. self.applyButton.title = NSLocalizedString("Save", comment: "")
  32. self.clearButton.title = NSLocalizedString("Clear", comment: "")
  33. }
  34. //MARK: IBACtion
  35. @IBAction func closeAction(_ sender: Any) {
  36. self.dismiss(self)
  37. }
  38. @IBAction func clearAction(_ sender: Any) {
  39. self.signTextField.stringValue = ""
  40. }
  41. @IBAction func cancelAction(_ sender: Any) {
  42. self.dismiss(self)
  43. }
  44. @IBAction func saveAction(_ sender: Any) {
  45. guard let callBack = self.actionBlock else {
  46. return
  47. }
  48. callBack(self, self.signTextField.stringValue)
  49. self.cancelAction(NSButton())
  50. }
  51. }