Bladeren bron

【注释】添加超链接,定位目标页面功能,未支持单击选择目标区域功能(已修复)

tangchao 1 jaar geleden
bovenliggende
commit
c5043b30f4

+ 17 - 4
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m

@@ -1830,8 +1830,8 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     NSUInteger eventMask = NSEventMaskLeftMouseUp | NSEventMaskLeftMouseDragged;
     CGRect rect = CGRectZero;
     while (YES) {
-        theEvent = [window nextEventMatchingMask:eventMask];
-        if ([theEvent type] == NSEventTypeLeftMouseUp) {
+        NSEvent *nextEvent = [window nextEventMatchingMask:eventMask];
+        if ([nextEvent type] == NSEventTypeLeftMouseUp) {
             if (!CGSizeEqualToSize(rect.size, CGSizeZero)) {
                 if ([self.activeAnnotation isKindOfClass:[CPDFLinkAnnotation class]]) {
                     CPDFLinkAnnotation *linkAnnotation = (CPDFLinkAnnotation *)self.activeAnnotation;
@@ -1843,13 +1843,26 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                         [self.pdfListViewDelegate PDFListViewLinkDestinationEnd:self withActiveAnnotation:self.activeAnnotation];
                     }
                 }
+            } else {
+                if ([lastMouseEvent isEqual:theEvent]) { // 点击事件(没有拖拽)
+                    if ([self.activeAnnotation isKindOfClass:[CPDFLinkAnnotation class]]) {
+                        CPDFLinkAnnotation *linkAnnotation = (CPDFLinkAnnotation *)self.activeAnnotation;
+                        CPDFDestination *destination = [[CPDFDestination alloc]initWithDocument:self.document pageIndex:[self.document indexForPage:page] atPoint:point zoom:self.scaleFactor];
+                        [linkAnnotation setDestination:destination];
+                        self.isSetLinkDestinationArea = NO;
+                        [self goToRect:linkAnnotation.bounds onPage:self.activeAnnotation.page];
+                        if([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewLinkDestinationEnd:withActiveAnnotation:)]) {
+                            [self.pdfListViewDelegate PDFListViewLinkDestinationEnd:self withActiveAnnotation:self.activeAnnotation];
+                        }
+                    }
+                }
             }
             break;
-        } else if ([theEvent type] == NSEventTypeLeftMouseDragged) {
+        } else if ([nextEvent type] == NSEventTypeLeftMouseDragged) {
             rect = [self doResizeLinkWithEvent:lastMouseEvent fromPoint:point originalBounds:originalBounds page:page resizeHandle:&resizeHandle];
             bezierPath = [NSBezierPath bezierPathWithRect:rect];
             [layer setPath:[bezierPath PDFListViewCGPath]];
-            lastMouseEvent = theEvent;
+            lastMouseEvent = nextEvent;
         }
     }