Browse Source

【fix】【内容编辑】选中文本框-弹出悬浮弹窗,滚动页面后,弹窗跑版

TangChao 7 months ago
parent
commit
0025b9f113

+ 11 - 3
PDF Office/PDF Master/Class/PDFTools/EditPDF/Tools/KMEditPDfHanddler.swift

@@ -560,6 +560,10 @@ extension KMEditPDfHanddler {
             let winFrame = self.listView?.window?.frame ?? .zero
             let view: NSView? = nil
             var position = self.listView?.convert(areaBounds.origin, to: view) ?? .zero
+            if position.y > winFrame.height {
+                self.hiddenPopWindow()
+                return
+            }
             position.x += winFrame.origin.x
             position.y += winFrame.origin.y
             position.y += areaBounds.size.height
@@ -575,9 +579,13 @@ extension KMEditPDfHanddler {
             }
             var y = max(0, position.y)
             
-            let screenFrame = NSScreen.main?.frame ?? .zero
-            if y + 44 + 40 >= screenFrame.size.height {
-                y = screenFrame.size.height - 44 - 40
+//            let screenFrame = NSScreen.main?.frame ?? .zero
+//            let winMaxY = NSMaxY(winFrame)
+            let height = NSHeight(winFrame)
+            if y + 44 + 40-20 >= height {
+//            if y + 44 + 40 + 40 >= screenFrame.size.height {
+//                y = screenFrame.size.height - 44 - 40 - 40
+                y = height - 44 - 40 + 20
             }
             
             let wframe = NSMakeRect(x, y, width, 44)

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/KMEditPDFTextPropertyViewController.swift

@@ -790,7 +790,7 @@ class KMEditPDFTextPropertyViewController: NSViewController {
                     if let styleName = self.listView.editingSelectionCFont(byRangeEdit: area)?.styleName, styleName.isEmpty == false {
                         self.fontStyleVC?.stringValue = styleName
                     } else {
-                        let styleNames = CPDFFont.fontNames(forFamilyName: self.listView.editingSelectionCFont(with: area).familyName)
+                        let styleNames = CPDFFont.fontNames(forFamilyName: self.listView.editingSelectionCFont(with: area)?.familyName ?? "")
                         if let styleN = styleNames.first, styleN.isEmpty == false {
                             self.fontStyleVC?.stringValue = styleN
                         } else {