Browse Source

【左边栏】搜索列表补充菜单

tangchao 1 year ago
parent
commit
3fbc20a0cb

+ 49 - 44
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift

@@ -828,7 +828,7 @@ class KMLeftSideViewController: KMSideViewController {
         self.groupedFindTableView.delegate = self
         self.groupedFindTableView.dataSource = self
         self.thumbnailTableView.menu?.delegate = self
-//        [[findTableView menu] setDelegate:mainController];
+        self.findTableView.menu?.delegate = self
 //        [[groupedFindTableView menu] setDelegate:mainController];
         
         self.tocOutlineView.doubleAction = #selector(goToSelectedOutlineItem)
@@ -4431,52 +4431,53 @@ extension KMLeftSideViewController: NSMenuDelegate {
                 var tName = self.listView.document.documentURL.lastPathComponent
                 item?.submenu = NSSharingServicePicker.menu(forSharingItems: [self.listView.document.documentURL], subjectContext: tName, withTarget: self, selector: #selector(sharePage), serviceDelegate: nil)
             }
-        }
-//        else if ([menu isEqual:[leftSideController.findTableView menu]]) {
-//            NSIndexSet *rowIndexes = [leftSideController.findTableView selectedRowIndexes];
-//            NSInteger row = [leftSideController.findTableView clickedRow];
-//            if (row != -1) {
-//                if ([rowIndexes containsIndex:row] == NO)
-//                    rowIndexes = [NSIndexSet indexSetWithIndex:row];
+        } else if menu.isEqual(to: self.findTableView.menu) {
+            var rowIndexes = self.findTableView.selectedRowIndexes
+            var row = self.findTableView.clickedRow
+            if (row != -1) {
+                if rowIndexes.contains(row) == false {
+                    rowIndexes = IndexSet(integer: row)
+                }
 //                NSArray *selections = [[leftSideController.findArrayController arrangedObjects] objectsAtIndexes:rowIndexes];
 //                if ([pdfView hideNotes] == NO && [[self pdfDocument] allowsNotes]) {
-//                    item = [menu addItemWithTitle:NSLocalizedString(@"Add New Circle", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKCircleNote];
-//                    [item setRepresentedObject:selections];
-//                    item = [menu addItemWithTitle:NSLocalizedString(@"Add New Rectangle", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKSquareNote];
-//                    [item setRepresentedObject:selections];
-//                    item = [menu addItemWithTitle:NSLocalizedString(@"Add New Highlight", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKHighlightNote];
-//                    [item setRepresentedObject:selections];
-//                    item = [menu addItemWithTitle:NSLocalizedString(@"Add New Underline", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKUnderlineNote];
-//                    [item setRepresentedObject:selections];
-//                    item = [menu addItemWithTitle:NSLocalizedString(@"Add New Strikethrough", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKStrikeOutNote];
+                item = menu.addItem(withTitle: KMLocalizedString("Add New Circle", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 0)
+////                    [item setRepresentedObject:selections];
+                item = menu.addItem(withTitle: KMLocalizedString("Add New Rectangle", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 1)
+////                    [item setRepresentedObject:selections];
+                item = menu.addItem(withTitle: KMLocalizedString("Add New Highlight", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 2)
+////                    [item setRepresentedObject:selections];
+                item = menu.addItem(withTitle: KMLocalizedString("Add New Underline", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 3)
+////                    [item setRepresentedObject:selections];
+                item = menu.addItem(withTitle: KMLocalizedString("Add New Strikethrough", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 4)
 //                    [item setRepresentedObject:selections];
 //                }
-//            }
-//    //    }
-//    //    else if ([menu isEqual:[leftSideController.groupedFindTableView menu]]) {
-//    //        NSIndexSet *rowIndexes = [leftSideController.groupedFindTableView selectedRowIndexes];
-//    //        NSInteger row = [leftSideController.groupedFindTableView clickedRow];
-//    //        if (row != -1) {
-//    //            if ([rowIndexes containsIndex:row] == NO)
-//    //                rowIndexes = [NSIndexSet indexSetWithIndex:row];
-//    //            NSArray *selections = [[[leftSideController.groupedFindArrayController arrangedObjects] objectsAtIndexes:rowIndexes] valueForKeyPath:@"@unionOfArrays.matches"];
-//    //            item = [menu addItemWithTitle:NSLocalizedString(@"Select", @"Menu item title") action:@selector(selectSelections:) target:self];
-//    //            [item setRepresentedObject:selections];
-//    //            [menu addItem:[NSMenuItem separatorItem]];
-//    //            if ([pdfView hideNotes] == NO && [[self pdfDocument] allowsNotes]) {
-//    //                item = [menu addItemWithTitle:NSLocalizedString(@"Add New Circle", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKCircleNote];
-//    //                [item setRepresentedObject:selections];
-//    //                item = [menu addItemWithTitle:NSLocalizedString(@"Add New Rectangle", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKSquareNote];
-//    //                [item setRepresentedObject:selections];
-//    //                item = [menu addItemWithTitle:NSLocalizedString(@"Add New Highlight", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKHighlightNote];
-//    //                [item setRepresentedObject:selections];
-//    //                item = [menu addItemWithTitle:NSLocalizedString(@"Add New Underline", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKUnderlineNote];
-//    //                [item setRepresentedObject:selections];
-//    //                item = [menu addItemWithTitle:NSLocalizedString(@"Add New Strikethrough", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKStrikeOutNote];
-//    //                [item setRepresentedObject:selections];
-//    //            }
-//    //        }
-//        } else if ([menu isEqual:[rightSideController.snapshotTableView menu]]) {
+            }
+    //    }
+    //    else if ([menu isEqual:[leftSideController.groupedFindTableView menu]]) {
+    //        NSIndexSet *rowIndexes = [leftSideController.groupedFindTableView selectedRowIndexes];
+    //        NSInteger row = [leftSideController.groupedFindTableView clickedRow];
+    //        if (row != -1) {
+    //            if ([rowIndexes containsIndex:row] == NO)
+    //                rowIndexes = [NSIndexSet indexSetWithIndex:row];
+    //            NSArray *selections = [[[leftSideController.groupedFindArrayController arrangedObjects] objectsAtIndexes:rowIndexes] valueForKeyPath:@"@unionOfArrays.matches"];
+    //            item = [menu addItemWithTitle:NSLocalizedString(@"Select", @"Menu item title") action:@selector(selectSelections:) target:self];
+    //            [item setRepresentedObject:selections];
+    //            [menu addItem:[NSMenuItem separatorItem]];
+    //            if ([pdfView hideNotes] == NO && [[self pdfDocument] allowsNotes]) {
+    //                item = [menu addItemWithTitle:NSLocalizedString(@"Add New Circle", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKCircleNote];
+    //                [item setRepresentedObject:selections];
+    //                item = [menu addItemWithTitle:NSLocalizedString(@"Add New Rectangle", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKSquareNote];
+    //                [item setRepresentedObject:selections];
+    //                item = [menu addItemWithTitle:NSLocalizedString(@"Add New Highlight", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKHighlightNote];
+    //                [item setRepresentedObject:selections];
+    //                item = [menu addItemWithTitle:NSLocalizedString(@"Add New Underline", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKUnderlineNote];
+    //                [item setRepresentedObject:selections];
+    //                item = [menu addItemWithTitle:NSLocalizedString(@"Add New Strikethrough", @"Menu item title") action:@selector(addAnnotationsForSelections:) target:self tag:SKStrikeOutNote];
+    //                [item setRepresentedObject:selections];
+    //            }
+    //        }
+        }
+//        else if ([menu isEqual:[rightSideController.snapshotTableView menu]]) {
 //            NSInteger row = [rightSideController.snapshotTableView clickedRow];
 //            if (row != -1) {
 //                SKSnapshotWindowController *controller = [[rightSideController.snapshotArrayController arrangedObjects] objectAtIndex:row];
@@ -4517,7 +4518,7 @@ extension KMLeftSideViewController: NSMenuDelegate {
 //                [item setRepresentedObject:controller];
 //            }
 //        }
-        else if menu.isEqual(to: self.noteOutlineView.menu) {
+    else if menu.isEqual(to: self.noteOutlineView.menu) {
             //            NSArray *items;
             var rowIndexes = self.noteOutlineView.selectedRowIndexes
             let row = self.noteOutlineView.clickedRow
@@ -4742,6 +4743,10 @@ extension KMLeftSideViewController {
         KMPrint("KMLeftSideViewController-removeAllAnnotations...")
     }
     
+    @objc func addAnnotationsForSelections(_ sender: AnyObject?) {
+        KMPrint("KMLeftSideViewController-addAnnotationsForSelections...")
+    }
+    
     private func _tableView(_ tv: NSTableView, cutRowsWithIndexes rowIndexes: IndexSet) {
 //        if tv.isEqual(to: self.thumbnailTableView) {
 //            self._copysPages.removeAll()