Revision: 14842
          http://sourceforge.net/p/skim-app/code/14842
Author:   hofman
Date:     2024-12-18 16:45:52 +0000 (Wed, 18 Dec 2024)
Log Message:
-----------
Check for both next and previous menu items, as either one can be missing

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

Modified: trunk/SKSecondaryPDFView.m
===================================================================
--- trunk/SKSecondaryPDFView.m  2024-12-18 10:27:08 UTC (rev 14841)
+++ trunk/SKSecondaryPDFView.m  2024-12-18 16:45:52 UTC (rev 14842)
@@ -537,7 +537,7 @@
         selectionActions = [[NSSet alloc] initWithObjects:@"copy:", 
@"_searchInSpotlight:", @"_searchInGoogle:", @"_searchInDictionary:", 
@"_revealSelection:", nil];
     NSMenu *menu = [super menuForEvent:theEvent];
     NSMenuItem *item;
-    NSInteger i = 0;
+    NSInteger i = 0, iNext, iPrev;
     
     if ([[menu itemAtIndex:0] view] != nil) {
         [menu removeItemAtIndex:0];
@@ -590,8 +590,15 @@
         [item setAlternate:YES];
     }
     
-    i = [menu indexOfItemWithTarget:self 
andAction:NSSelectorFromString(@"goToNextPage:")];
-    i = i == NSNotFound || i == 0 ? [menu numberOfItems] : i - 1;
+    iNext = [menu indexOfItemWithTarget:self 
andAction:@selector(goToNextPage:)];
+    iPrev = [menu indexOfItemWithTarget:self 
andAction:@selector(goToPreviousPage:)];
+    if (iNext == -1)
+        i = iPrev;
+    else if (iPrev == -1)
+        i = iNext;
+    else
+        i = MIN(iPrev, iNext);
+    i = i == -1 || i == 0 ? [menu numberOfItems] : i - 1;
     
     [menu insertItemWithTitle:NSLocalizedString(@"Scroll Tool", @"Menu item 
title") action:@selector(changeToolMode:) target:self tag:0 atIndex:i];
     [menu insertItemWithTitle:NSLocalizedString(@"Text Tool", @"Menu item 
title") action:@selector(changeToolMode:) target:self tag:1 atIndex:i];

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to