Browse Source

【超链接】- 悬停

liujiajie 11 months ago
parent
commit
040e5f243d

+ 10 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m

@@ -387,7 +387,16 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
 }
 
 - (void)mouseExited:(NSEvent *)event {
-    [super mouseExited:event];
+    NSTrackingArea *eventArea = [event trackingArea];
+    CPDFAnnotation *annotation;
+    
+    if ([eventArea owner] == self && (annotation = [[eventArea userInfo] objectForKey:SKAnnotationKey])) {
+        if ([annotation isEqual:[[KMImageToolTipWindow shared] context]]){
+            [[KMImageToolTipWindow shared] fadeOut];
+        }
+    } else {
+        [super mouseExited:event];
+    }
     [[NSCursor arrowCursor] set];
 }
 

+ 3 - 2
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMImageToolTipWindow.swift

@@ -50,6 +50,7 @@ class KMImageToolTipWindow: KMAnimatedBorderlessWindow {
     }
     
     override func fadeOut() {
+        self.context = nil
         self.point = .zero
         super.fadeOut()
     }
@@ -81,8 +82,8 @@ extension KMImageToolTipWindow {
     @objc private func _showDelayed() {
         let thePoint = self.point == .zero ? NSEvent.mouseLocation : self.point
         var contentRect: NSRect = .zero
-        var screenRect = NSScreen.screen(for: thePoint)?.frame ?? .zero
-        var image = self.context?.toolTipImage()
+        let screenRect = NSScreen.screen(for: thePoint)?.frame ?? .zero
+        let image = self.context?.toolTipImage()
         if (image != nil) {
             self.backgroundImage = image