浏览代码

【幻灯片】顶部菜单-查看-幻灯片选项,勾选独特的页面切换效果,滑动期间条,数据不变

liujiajie 6 月之前
父节点
当前提交
723df7d2bc

+ 27 - 3
PDF Office/PDF Master/Class/PDFWindowController/MainWindowController/SKPresentationOptionsSheetController.swift

@@ -183,7 +183,7 @@ class SKPresentationOptionsSheetController: KMBaseWindowController {
         self.effectPopUpButton.target = self
         self.effectPopUpButton.action = #selector(effectButtonAction)
         
-        self.durationTF.formatter = NumberFormatter()
+//        self.durationTF.formatter = NumberFormatter()
         self.durationTF.delegate = self
         
         self.screeBtn.target = self
@@ -577,11 +577,35 @@ class SKPresentationOptionsSheetController: KMBaseWindowController {
 extension SKPresentationOptionsSheetController: NSTextFieldDelegate {
     func controlTextDidChange(_ obj: Notification) {
         if self.durationTF.isEqual(to: obj.object) {
-            self.durationSlider.floatValue = self.durationTF.floatValue
+//            self.durationSlider.floatValue = self.durationTF.floatValue
             // 更新数据
-            self._updateInfo(key: KMDurationName, value: self.durationTF.floatValue)
+//            self._updateInfo(key: KMDurationName, value: self.durationTF.floatValue)
         }
     }
+    func controlTextDidEndEditing(_ obj: Notification) {
+        if self.durationTF.isEqual(to: obj.object) {
+            if checkString(str: self.durationTF.stringValue) {
+                self.durationSlider.floatValue = self.durationTF.floatValue
+                // 更新数据
+                self._updateInfo(key: KMDurationName, value: self.durationTF.floatValue)
+            }else{
+                self.durationTF.stringValue = "1.0"
+            }
+        }
+    }
+//    func controlTextDidBeginEditing(_ obj: Notification) {
+//        if self.durationTF.isEqual(to: obj.object) {
+//            
+//        }
+//    }
+    func checkString(str: String) -> Bool {
+        let reg = "^[1-9]d*.d*|0.d*[1-9]d*|0?.0+|0$"
+        let pre = NSPredicate(format: "SELF MATCHES %@", reg)
+        if pre.evaluate(with: str) {
+            return true
+        }
+        return false
+    }
 }
 
 // MARK: - NSWindowDelegate