Browse Source

【页面编辑】提取item调整pop

tangchao 1 year ago
parent
commit
6e1dc75661

+ 21 - 1
PDF Office/PDF Master/Class/PDFTools/PageEdit/View/KMPDFEditToolbar.swift

@@ -286,6 +286,20 @@ class KMPDFEditToolbar: NSView {
         }
     }
     
+    @objc private func _extractMenuItemAction(_ sender: NSMenuItem) {
+        if (sender.tag == 1) {
+            guard let callback = self.itemClick else {
+                return
+            }
+            callback(self, KMPageEditType.extract_selected_pages)
+        } else if (sender.tag == 2) {
+            guard let callback = self.itemClick else {
+                return
+            }
+            callback(self, KMPageEditType.extract.rawValue)
+        }
+    }
+    
     @objc func replaceMenuAction(sender: KMToolbarClickButton?) {
         guard let callback = self.itemClick else {
             return
@@ -513,9 +527,15 @@ extension KMPDFEditToolbar: KMToolbarViewDelegate {
             item?.toolTip = NSLocalizedString("Exctract selected pages", comment: "")
             item?.titleName = NSLocalizedString("Extract", comment: "")
             item?.boxImagePosition = .imageExpandLeft
-            item?.btnAction = #selector(extractMenuAction)
+//            item?.btnAction = #selector(extractMenuAction)
+            item?.needExpandAction = true
             
             let menuItem = NSMenuItem.init(title: "Extract", action: #selector(extractMenuAction), target: self)
+            let subMenu = NSMenu()
+            menuItem.submenu = subMenu
+            subMenu.addItem(title: NSLocalizedString("Extract selected pages", comment: ""), action: #selector(_extractMenuItemAction) , target: self, tag: 1)
+            subMenu.addItem(title: NSLocalizedString("Extract", comment: ""), action: #selector(_extractMenuItemAction) , target: self, tag: 2)
+            
             item?.menuFormRepresentation = menuItem
         } else if (identifier == KMToolbarPageEditReplaceItemIdentifier) {
             item?.image = NSImage(named: KMImageNameToolbarReplace)