Revision: 15828
http://sourceforge.net/p/skim-app/code/15828
Author: hofman
Date: 2025-11-25 10:28:32 +0000 (Tue, 25 Nov 2025)
Log Message:
-----------
do jump page after scrolling with page up/down again
Modified Paths:
--------------
trunk/SKBasePDFView.h
trunk/SKBasePDFView.m
Modified: trunk/SKBasePDFView.h
===================================================================
--- trunk/SKBasePDFView.h 2025-11-25 10:12:00 UTC (rev 15827)
+++ trunk/SKBasePDFView.h 2025-11-25 10:28:32 UTC (rev 15828)
@@ -44,6 +44,7 @@
@interface SKBasePDFView : PDFView {
NSInteger minHistoryIndex;
+ NSInteger keyDirection;
}
- (void)colorFiltersDidChange;
Modified: trunk/SKBasePDFView.m
===================================================================
--- trunk/SKBasePDFView.m 2025-11-25 10:12:00 UTC (rev 15827)
+++ trunk/SKBasePDFView.m 2025-11-25 10:28:32 UTC (rev 15828)
@@ -390,6 +390,18 @@
[super goToDestination:destination];
}
+- (void)keyDown:(NSEvent *)event {
+ unichar ch = [event firstCharacter];
+ if (ch == NSPageDownFunctionKey || ch == NSDownArrowFunctionKey)
+ keyDirection = 1;
+ else if (ch == NSPageUpFunctionKey || ch == NSUpArrowFunctionKey)
+ keyDirection = -1;
+ else if (ch == SKSpaceCharacter)
+ keyDirection = ([event modifierFlags] & NSEventModifierFlagShift) ? -1
: 1;
+ [super keyDown:event];
+ keyDirection = 0;
+}
+
// PDFView binds PageDown to scrollPageUp: and ArrowDown to scrollPageUp: and
v.v. (wrong!)
// the clipView is not flipped (wrong!)
// ... at least until macOS 15, but macOS 26 seems to scroll in the wrong
direction
@@ -408,12 +420,15 @@
scrollView = [self scrollView];
clipView = [scrollView contentView];
bounds = [clipView bounds];
+ } else if (hasHorizontalLayout(self) && (keyDirection == -1 ? [self
canGoToPreviousPage] : keyDirection == 1 ? [self canGoToNextPage] : NO)) {
+ clipView = [[self scrollView] contentView];
+ bounds = [clipView bounds];
}
// always call super, as it also updates the current page
[super scrollPageUp:sender];
- if (clipView) {
+ if (scrollView) {
CGFloat inset = [clipView contentInsets].top;
CGFloat height = NSHeight(bounds) - inset;
CGFloat offset = fmax(height - [scrollView verticalPageScroll], 0.5 *
height);
@@ -438,6 +453,14 @@
[self verticallyScrollToTop];
else if (currentPageIndex < pageIndex)
[self verticallyScrollToBottom];
+ } else if (clipView && NSEqualPoints([clipView bounds].origin,
bounds.origin)) {
+ if (keyDirection == -1) {
+ [self goToPreviousPage:sender];
+ [self verticallyScrollToBottom];
+ } else {
+ [self goToNextPage:sender];
+ [self verticallyScrollToTop];
+ }
}
}
@@ -455,12 +478,15 @@
scrollView = [self scrollView];
clipView = [scrollView contentView];
bounds = [clipView bounds];
+ } else if (hasHorizontalLayout(self) && (keyDirection == 1 ? [self
canGoToNextPage] : keyDirection == -1 ? [self canGoToPreviousPage] : NO)) {
+ clipView = [[self scrollView] contentView];
+ bounds = [clipView bounds];
}
// always call super, as it also updates the current page
[super scrollPageDown:sender];
- if (clipView) {
+ if (scrollView) {
CGFloat inset = [clipView contentInsets].top;
CGFloat height = NSHeight(bounds) - inset;
CGFloat offset = fmax(height - [scrollView verticalPageScroll], 0.5 *
height);
@@ -485,6 +511,14 @@
[self verticallyScrollToBottom];
else if (currentPageIndex > pageIndex)
[self verticallyScrollToTop];
+ } else if (clipView && NSEqualPoints([clipView bounds].origin,
bounds.origin)) {
+ if (keyDirection == 1) {
+ [self goToNextPage:sender];
+ [self verticallyScrollToTop];
+ } else {
+ [self goToPreviousPage:sender];
+ [self verticallyScrollToBottom];
+ }
}
}
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