Browse Source

【BOTA】缩略图快捷键添加

lizhe 1 year ago
parent
commit
7b18089f47

+ 19 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/Thumbnail/KMThumbnailViewController.swift

@@ -55,6 +55,7 @@ class KMThumbnailViewController: NSViewController {
         
         self.initNotification()
         
+        self.view.window?.makeFirstResponder(self)
     }
     
     func initMenu () {
@@ -554,6 +555,21 @@ class KMThumbnailViewController: NSViewController {
     
 }
 
+protocol KMThumbnailViewControllerAction {}
+extension KMThumbnailViewController: KMThumbnailViewControllerAction {
+    @IBAction func cut(_ sender: Any) {
+        self.cutItemAction(menu: NSMenuItem())
+    }
+    
+    @IBAction func copy(_ sender: Any) {
+        self.copyItemAction(menu: NSMenuItem())
+    }
+    
+    @IBAction func paste(_ sender: Any) {
+        self.pastePageItemAction(menu: NSMenuItem())
+    }
+}
+
 //MARK: KMPDFThumbnailViewDelegate
 extension KMThumbnailViewController : KMPDFThumbnailViewDelegate {
     func thumbnailView(thumbanView: KMPDFThumbnailView, didSelectPageAtIndex index: UInt) {
@@ -668,10 +684,13 @@ extension KMThumbnailViewController : NSMenuDelegate,NSMenuItemValidation {
         
         item = menu.addItem(withTitle: NSLocalizedString("Copy", comment: ""), action: #selector(copyItemAction), target: self)
         item.representedObject = row
+        item.keyEquivalent = "c"
         item = menu.addItem(withTitle: NSLocalizedString("Cut", comment: ""), action: #selector(cutItemAction), target: self)
         item.representedObject = row
+        item.keyEquivalent = "x"
         item = menu.addItem(withTitle: NSLocalizedString("Paste", comment: ""), action: #selector(pastePageItemAction), target: self)
         item.representedObject = row
+        item.keyEquivalent = "v"
         
         menu.addItem(NSMenuItem.separator())