Revision: 15247
          http://sourceforge.net/p/skim-app/code/15247
Author:   hofman
Date:     2025-05-21 09:28:07 +0000 (Wed, 21 May 2025)
Log Message:
-----------
Allow clicking local links in presentation

Modified Paths:
--------------
    trunk/SKPresentationView.m

Modified: trunk/SKPresentationView.m
===================================================================
--- trunk/SKPresentationView.m  2025-05-21 09:12:57 UTC (rev 15246)
+++ trunk/SKPresentationView.m  2025-05-21 09:28:07 UTC (rev 15247)
@@ -55,6 +55,7 @@
 #import "NSView_SKExtensions.h"
 #import "PDFPage_SKExtensions.h"
 #import "PDFDocument_SKExtensions.h"
+#import "PDFAnnotation_SKExtensions.h"
 
 #define NAVIGATION_BOTTOM_EDGE_HEIGHT 5.0
 
@@ -611,6 +612,20 @@
     return [transform transformPoint:point];
 }
 
+- (PDFAnnotation *)linkAnotationAtPoint:(NSPoint)point {
+    if (page == nil)
+        return nil;
+    
+    point = [self convertPointToPage:point];
+    
+    for (PDFAnnotation *annotation in [[page annotations] 
reverseObjectEnumerator]) {
+        if ([annotation isLink] && [annotation hitTest:point])
+            return annotation;
+    }
+    
+    return nil;
+}
+
 #pragma mark Accessors
 
 - (BOOL)canBecomeKeyView {
@@ -786,7 +801,11 @@
     if ([pageLayer opacity] <= 0.0) {
         [pageLayer setOpacity:1.0];
     } else if ([NSApp willDragMouse] == NO) {
-        [self goToNextPage:self];
+        PDFDestination *link = [[self linkAnotationAtPoint:[theEvent 
locationInView:self]] destination];
+        if (link)
+            [self setPage:[link page]];
+        else
+            [self goToNextPage:self];
     } else if (IS_TABLET_EVENT(theEvent, NSPointingDeviceTypePen) == NO && 
([[self window] styleMask] & NSWindowStyleMaskResizable) != 0 && 
NSEqualRects([[self window] frame], [[[self window] screen] frame]) == NO && 
(pvFlags.enableDrawing == NO || ([theEvent modifierFlags] & 
NSEventModifierFlagShift) == 0)) {
         pvFlags.cursorHidden = NO;
         [[NSCursor closedHandCursor] set];
@@ -807,8 +826,8 @@
 
 - (void)mouseMoved:(NSEvent *)theEvent {
     pvFlags.cursorHidden = NO;
-
-    [self setCursorAndAutoHide];
+    [self setCursorForMouse:theEvent];
+    [self performSelectorOnce:@selector(doAutoHide) 
afterDelay:AUTO_HIDE_DELAY];
     
     if (navigationMode != SKNavigationNone && [navWindow isVisible] == NO) {
         if (navigationMode == SKNavigationEverywhere && [cursorWindow 
isVisible] == NO && NSPointInRect([theEvent locationInWindow], [[[self window] 
contentView] frame])) {
@@ -1114,6 +1133,8 @@
         [[NSCursor arrowCursor] set];
     else if (pvFlags.cursorHidden)
         [[NSCursor emptyCursor] set];
+    else if ([[self linkAnotationAtPoint:point] destination])
+        [[NSCursor pointingHandCursor] set];
     else if (pvFlags.useArrowCursor)
         [[NSCursor arrowCursor] set];
     else if (pvFlags.removeLaserPointerShadow)

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to