Przeglądaj źródła

【2025】【综合】右键弹窗完善

niehaoyu 1 miesiąc temu
rodzic
commit
82e9cb87bb

+ 7 - 3
PDF Office/KMComponentLibrary/KMComponentLibrary/View/GroupItem/ComponentGroup.swift

@@ -150,10 +150,14 @@ public class ComponentGroup: NSView, NibLoadable {
     
     //MARK: - Show
     //Point是相对于当前WIndow的point,
+    
     public func showWithPoint(_ point: CGPoint, relativeTo positioningView: NSView?) {
-        
+        self.showWithPoint(point, relativeTo: positioningView, withWindow: NSApplication.shared.keyWindow)
+    }
+    
+    public func showWithPoint(_ point: CGPoint, relativeTo positioningView: NSView?, withWindow window: NSWindow?) {
         var screenRect = NSScreen.main!.frame
-        if let keyWindow = NSApplication.shared.keyWindow, let screen = keyWindow.screen {
+        if let keyWindow = window, let screen = keyWindow.screen {
             screenRect = screen.visibleFrame
         }
         if self.windowVC.window?.isVisible == true {
@@ -183,7 +187,7 @@ public class ComponentGroup: NSView, NibLoadable {
             
         } else {
             var editPoint = point
-            if let keyWindow = NSApplication.shared.keyWindow {
+            if let keyWindow = window {
                 editPoint.x += keyWindow.frame.origin.x - screenRect.origin.x
                 editPoint.y += keyWindow.frame.origin.y - screenRect.origin.y
             }

+ 4 - 2
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -5480,6 +5480,8 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
     func pdfListViewMenu(forEvent pdfListView: CPDFListView!, for theEvent: NSEvent!, click menu: AutoreleasingUnsafeMutablePointer<NSMenu?>!, isMoveSelectAnno: Bool) {
         toggleClosePopUIWindow()
 
+        self.view.window?.orderFront(nil)
+        
         var pagePoint = CGPoint.zero
         let point = self.view.convert(theEvent.locationInWindow, from: nil)
         
@@ -5732,7 +5734,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: nil)
+                groupListMenuGroup?.showWithPoint(CGPoint(x: point.x, y: point.y - menuStruct.viewHeight), relativeTo: nil, withWindow: self.view.window)
 
             }
         } else {
@@ -5750,7 +5752,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: nil)
+            groupListMenuGroup?.showWithPoint(CGPoint(x: point.x, y: point.y - menuStruct.viewHeight), relativeTo: nil, withWindow: self.view.window)
         }
     }