Browse Source

【fix】【内容编辑】文本/图片 在阅读区右侧位置,不显示悬浮菜单

tangchao 7 months ago
parent
commit
5d64a0e072

+ 7 - 2
PDF Office/PDF Master/Class/PDFTools/EditPDF/Tools/KMEditPDfHanddler.swift

@@ -525,7 +525,12 @@ extension KMEditPDfHanddler {
             position.y += 26
             
             position.x += (areaBounds.size.width*0.5-win.frame.size.width*0.5)
-            let x = max(0, position.x)
+            var x = max(0, position.x)
+            let width = win.frame.size.width
+            let offsetX = x + width - NSMaxX(winFrame)
+            if offsetX > 0 { // 超出右编辑
+                x -= offsetX
+            }
             var y = max(0, position.y)
             
             let screenFrame = NSScreen.main?.frame ?? .zero
@@ -533,7 +538,7 @@ extension KMEditPDfHanddler {
                 y = screenFrame.size.height - 44 - 40
             }
             
-            let wframe = NSMakeRect(x, y, win.frame.size.width, 44)
+            let wframe = NSMakeRect(x, y, width, 44)
             win.setFrame(wframe, display: true)
             
             if CGRectContainsRect(winFrame, wframe) == false {

+ 5 - 1
PDF Office/PDF Master/Class/PDFTools/EditPDF/Window/KMEditPDFPopToolBarWindow.swift

@@ -178,7 +178,11 @@ import Cocoa
         position.y += positioningRect.size.height
         position.y += 26
         position.x += (positioningRect.size.width*0.5-width*0.5)
-        let x = max(0, position.x)
+        var x = max(0, position.x)
+        let offsetX = x + width - NSMaxX(winFrame)
+        if offsetX > 0 { // 超出右编辑
+            x -= offsetX
+        }
         var y = max(0, position.y)
         
         let screenFrame = NSScreen.main?.frame ?? .zero