Browse Source

【工具栏】- 放大缩小按钮状态修改

liaoxiaoyue 1 year ago
parent
commit
573151f1ec

+ 17 - 0
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -1273,6 +1273,21 @@ extension KMMainViewController {
             toItem.unEnabled = true
         }
     }
+    
+    func updateZoomInOutButtonState() {
+        let item : KMToolBoxItem = (self.toolbarController.mainToolBarView?.toolbarItemFindItemIdentifiers(value: KMDocumentZoomToolbarItemIdentifier))!
+        let toItem : KMToolBoxItem = (self.toolbarController.mainToolBarView?.toolbarItemFindItemIdentifiers(value: KMDocumentZoomOutToolbarItemIdentifier))!
+        if self.listView.canZoomIn {
+            item.unEnabled = false
+        } else {
+            item.unEnabled = true
+        }
+        if self.listView.canZoomOut {
+            toItem.unEnabled = false
+        } else {
+            toItem.unEnabled = true
+        }
+    }
 }
 
 extension KMMainViewController: KMSecondaryViewControllerDelegate {
@@ -1349,10 +1364,12 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
     
     func changePDFViewZoomInAction() {
         self.listView.zoomIn(nil)
+        self.updateZoomInOutButtonState()
     }
     
     func changePDFViewZoomOutAction() {
         self.listView.zoomOut(nil)
+        self.updateZoomInOutButtonState()
     }
     
     func changePDFViewGotoNextPageAction() {