Browse Source

【偏好设置】批注模块,虚线设置项处理

tangchao 1 year ago
parent
commit
a06a959a89

+ 27 - 0
PDF Office/PDF Master/Class/Common/LineInspector/KMLineInspector.swift

@@ -177,6 +177,9 @@ class KMLineInspector: NSWindowController {
         
         
         self.windowFrameAutosaveName = SKLineInspectorFrameAutosaveName
         self.windowFrameAutosaveName = SKLineInspectorFrameAutosaveName
         self._currentLineChangeAction = .no
         self._currentLineChangeAction = .no
+        
+        self.lineWidthField.formatter = NumberFormatter()
+        self.dashPatternField.formatter = NumberFormatter()
     }
     }
     
     
     private func _initValues() {
     private func _initValues() {
@@ -205,6 +208,8 @@ class KMLineInspector: NSWindowController {
         self.startLineStyleButton.action = #selector(startLineStyleAction)
         self.startLineStyleButton.action = #selector(startLineStyleAction)
         self.endLineStyleButton.target = self
         self.endLineStyleButton.target = self
         self.endLineStyleButton.action = #selector(endLineStyleAction)
         self.endLineStyleButton.action = #selector(endLineStyleAction)
+        self.lineWidthField.delegate = self
+        self.dashPatternField.delegate = self
     }
     }
     
     
     private func _initStyleImages() {
     private func _initStyleImages() {
@@ -587,3 +592,25 @@ extension KMLineInspector {
         self._currentLineChangeAction = .no
         self._currentLineChangeAction = .no
     }
     }
 }
 }
+
+extension KMLineInspector: NSTextFieldDelegate {
+    func controlTextDidChange(_ obj: Notification) {
+        if self.lineWidthField.isEqual(to: obj.object) {
+            let value = self.lineWidthField.doubleValue
+            if value < self.lineWidthSlider.minValue {
+                self.lineWidth = self.lineWidthSlider.minValue
+                self.lineWidthField.stringValue = String(format: "%.0f", self.lineWidth)
+            } else if value > self.lineWidthSlider.maxValue {
+                self.lineWidth = self.lineWidthSlider.maxValue
+                self.lineWidthField.stringValue = String(format: "%.0f", self.lineWidth)
+            } else {
+                self.lineWidth = value
+            }
+            self.lineWidthSlider.doubleValue = self.lineWidth
+        } else if self.dashPatternField.isEqual(to: obj.object) {
+            let cnt = self.dashPatternField.integerValue
+            let data = [CGFloat](repeating: 3.0, count: cnt)
+            self.dashPattern = data
+        }
+    }
+}