소스 검색

【2025】【PDFView】 多选右键菜单弹出问题及复制相关问题修改

dinglingui 1 개월 전
부모
커밋
6410a0e45b

+ 37 - 12
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFListViewExtension/CPDFListView+Event.m

@@ -689,25 +689,50 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     if (self.annotationType == CAnnotationTypeInk || self.annotationType == CAnnotationTypeEraser) {
         return nil;
     }
-    if([self.activeAnnotations count] > 1) {
-        CPDFAnnotation *newActiveAnnotation = nil;
-        if([self doClickAnnotationWithEvent:event forAnnotation:&newActiveAnnotation]) {
-            if ([self consistentTypeWithAnnotation:newActiveAnnotation]) {
-                if(![self.activeAnnotations containsObject:newActiveAnnotation]) {
-                    [self updateIsRightActiveAnnotations:@[newActiveAnnotation]];
-                    [self setNeedsDisplayAnnotation:newActiveAnnotation];
-                }
+    
+    CPDFAnnotation *newActiveAnnotation = nil;
+    
+    if (([self toolMode] == CTextToolMode ||
+         [self toolMode] == CNoteToolMode ||
+         [self toolMode] == CFormToolMode ||
+         [self toolMode] == CRedactToolMode) && [self hideNotes] == NO) {
+        
+        for (CPDFAnnotation *tAnnotation in page.annotations) {
+            if ([tAnnotation hitTest:pagePoint]) {
+                newActiveAnnotation = tAnnotation;
+                break;
             }
         }
         
-        if(self.activeAnnotations.count > 0) {
-            CPDFSelection *selection = [self creatImageCurrentSelectionForPoint:[event locationInPDFListView:self]];
-            if(selection && CPDFSelectionTypeImage == [selection selectionType]){
-                self.currentSelection = selection;
+        if (newActiveAnnotation) {
+            if ([newActiveAnnotation isKindOfClass:[CPDFWidgetAnnotation class]] ){
+                if(CFormToolMode != self.toolMode)
+                    newActiveAnnotation = nil;
+            } else if([newActiveAnnotation isKindOfClass:[CPDFRedactAnnotation class]]) {
+                if(CRedactToolMode != self.toolMode)
+                    newActiveAnnotation = nil;
+            } else if([newActiveAnnotation isKindOfClass:[CPDFLinkAnnotation class]]) {
+                if(CEditLinkToolMode != self.toolMode)
+                    newActiveAnnotation = nil;
+            }
+
+        }
+        
+        if(newActiveAnnotation) {
+            if(![self.activeAnnotations containsObject:newActiveAnnotation]) {
+                [self updateIsRightActiveAnnotations:@[newActiveAnnotation]];
+                [self setNeedsDisplayAnnotation:newActiveAnnotation];
             }
         }
     }
     
+    if(self.activeAnnotations.count > 0) {
+        CPDFSelection *selection = [self creatImageCurrentSelectionForPoint:[event locationInPDFListView:self]];
+        if(selection && CPDFSelectionTypeImage == [selection selectionType]){
+            self.currentSelection = selection;
+        }
+    }
+    
     if ([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewMenuForEvent:forEvent:clickMenu:isMoveSelectAnno:)]) {
         [self.pdfListViewDelegate PDFListViewMenuForEvent:self forEvent:event clickMenu:&menu isMoveSelectAnno:annotationSel!=nil];
     }

+ 10 - 8
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -5431,9 +5431,10 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
     }
     
     func pdfListViewMenu(forEvent pdfListView: CPDFListView!, for theEvent: NSEvent!, click menu: AutoreleasingUnsafeMutablePointer<NSMenu?>!, isMoveSelectAnno: Bool) {
-        
+        toggleClosePopUIWindow()
+
         var pagePoint = CGPoint.zero
-        let point = theEvent.locationInWindow
+        let point = self.view.convert(theEvent.locationInWindow, from: nil)
         
         let isShowPopUI:Bool = !SettingsManager.sharedInstance.showQuickActionBar
 
@@ -5444,7 +5445,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
                 groupListMenuGroup?.frame = CGRectMake(0, 0, 180, menuStruct.viewHeight)
                 groupListMenuGroup?.updateGroupInfo(menuStruct.menuitems)
     
-                groupListMenuGroup?.showWithPoint(CGPoint(x: point.x, y: point.y - menuStruct.viewHeight), relativeTo: pdfListView)
+                groupListMenuGroup?.showWithPoint(CGPoint(x: point.x, y: point.y - menuStruct.viewHeight), relativeTo: nil)
             } else {
                 var menuStringArr: [String] = []
                 let activeAnnotations = pdfListView.activeAnnotations as? [CPDFAnnotation]
@@ -5702,12 +5703,13 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
             groupListMenuGroup?.frame = CGRectMake(0, 0, 180, menuStruct.viewHeight)
             groupListMenuGroup?.updateGroupInfo(menuStruct.menuitems)
             
-            groupListMenuGroup?.showWithPoint(CGPoint(x: point.x, y: point.y - menuStruct.viewHeight), relativeTo: pdfListView)
+            groupListMenuGroup?.showWithPoint(CGPoint(x: point.x, y: point.y - menuStruct.viewHeight), relativeTo: nil)
         }
-        reloadPopUIWindow()
     }
     
     func pdfListViewMenuItemsEditing(at point: CGPoint, for page: CPDFPage!, menuItems: [NSMenuItem]!) -> [NSMenuItem]! {
+        toggleClosePopUIWindow()
+        
         var windowPoint = listView.convert(point, from: page)
         let view: NSView? = nil
         windowPoint = listView.convert(windowPoint, to: view)
@@ -5718,7 +5720,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
             groupListMenuGroup?.frame = CGRectMake(0, 0, 180, menuStruct.viewHeight)
             groupListMenuGroup?.updateGroupInfo(menuStruct.menuitems)
             
-            groupListMenuGroup?.showWithPoint(CGPoint(x: windowPoint.x, y: windowPoint.y - menuStruct.viewHeight), relativeTo: listView)
+            groupListMenuGroup?.showWithPoint(CGPoint(x: windowPoint.x, y: windowPoint.y - menuStruct.viewHeight), relativeTo: nil)
         } else {
             let isShowPopUI:Bool = !SettingsManager.sharedInstance.showQuickActionBar
             var menuStringArr: [String] = []
@@ -5885,7 +5887,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
             groupListMenuGroup?.frame = CGRectMake(0, 0, 180, menuStruct.viewHeight)
             groupListMenuGroup?.updateGroupInfo(menuStruct.menuitems)
             
-            groupListMenuGroup?.showWithPoint(CGPoint(x: windowPoint.x, y: windowPoint.y - menuStruct.viewHeight), relativeTo: listView)
+            groupListMenuGroup?.showWithPoint(CGPoint(x: windowPoint.x, y: windowPoint.y - menuStruct.viewHeight), relativeTo: nil)
         }
         
         return []
@@ -6636,7 +6638,7 @@ extension KMMainViewController: ComponentGroupDelegate {
                         if copyText.isEmpty == true {
                             copyText = markupContent
                         } else {
-                            copyText = "\n" + markupContent
+                            copyText = copyText + "\n" + markupContent
                         }
                     }
                 }