Revision: 15472
          http://sourceforge.net/p/skim-app/code/15472
Author:   hofman
Date:     2025-06-16 15:28:02 +0000 (Mon, 16 Jun 2025)
Log Message:
-----------
convenience accessor for pdfview of PDFAnnotation

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

Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m  2025-06-16 15:19:37 UTC (rev 15471)
+++ trunk/PDFAnnotation_SKExtensions.m  2025-06-16 15:28:02 UTC (rev 15472)
@@ -780,11 +780,14 @@
     return nil;
 }
 
+- (SKPDFView *)containingPdfView {
+    NSDocument *doc = [[self page] containingDocument];
+    return [doc isPDFDocument] ? [(SKMainDocument *)doc pdfView] : nil;
+}
+
 - (void)handleEditScriptCommand:(NSScriptCommand *)command {
     if ([self isEditable]) {
-        NSDocument *doc = [[self page] containingDocument];
-        if ([doc isPDFDocument])
-            [[(SKMainDocument *)doc pdfView] editAnnotation:self];
+        [[self containingPdfView] editAnnotation:self];
     }
 }
 
@@ -791,30 +794,25 @@
 - (BOOL)accessibilityPerformPress {
     if ([self isSkimNote] == NO)
         return NO;
-    NSDocument *doc = [[self page] containingDocument];
-    if ([doc respondsToSelector:@selector(pdfView)] == NO)
-        return NO;
-    [[(SKMainDocument *)doc pdfView] editAnnotation:self];
-    return YES;
+    SKPDFView *pdfView = [self containingPdfView];
+    [pdfView editAnnotation:self];
+    return pdfView != nil;
 }
 
 - (BOOL)accessibilityPerformPick {
     if ([self isSkimNote] == NO)
         return NO;
-    NSDocument *doc = [[self page] containingDocument];
-    if ([doc respondsToSelector:@selector(pdfView)] == NO)
-        return NO;
-    [[(SKMainDocument *)doc pdfView] setCurrentAnnotation:self];
-    return YES;
+    SKPDFView *pdfView = [self containingPdfView];
+    [pdfView setCurrentAnnotation:self];
+    return pdfView != nil;
 }
 
 - (BOOL)accessibilityPerformShowMenu {
     if ([self isSkimNote] == NO)
         return NO;
-    NSDocument *doc = [[self page] containingDocument];
-    if ([doc respondsToSelector:@selector(pdfView)] == NO)
+    SKPDFView *pdfView = [self containingPdfView];
+    if (pdfView == nil)
         return NO;
-    PDFView *pdfView = [(SKMainDocument *)doc pdfView];
     NSPoint point = SKCenterPoint([pdfView convertRect:[self bounds] 
fromPage:[self page]]);
     NSEvent *event = [NSEvent mouseEventWithType:NSEventTypeRightMouseDown
                                         location:[pdfView convertPoint:point 
toView:nil]

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