James Widman
2014-08-16 17:29:55 UTC
Hi all,
Issue: in OS X 10.10 (14A314h), NSKeyDown events for the pagedown key and the space bar result in a call to goToPreviousPage, and pageup/shift-space result in a call to goToNextPage.
I wrote a patch for this (below) but:
- I’m a newbie with Skim’s source code (and Objective-C in general);
- I’m not sure where keyboard bindings are normally supposed to happen; and
- I’m not sure whether this is a bug in Yosemite (though Preview.app seems well behaved).
Criticism welcome!
—James
Index: SKPDFView.m
===================================================================
--- SKPDFView.m (revision 8385)
+++ SKPDFView.m (working copy)
@@ -1045,11 +1045,18 @@
}
} else {
// Normal or fullscreen mode
- BOOL isLeftRightArrow = eventChar == NSRightArrowFunctionKey || eventChar == NSLeftArrowFunctionKey;
- BOOL isUpDownArrow = eventChar == NSUpArrowFunctionKey || eventChar == NSDownArrowFunctionKey;
- BOOL isArrow = isLeftRightArrow || isUpDownArrow;
-
- if ((eventChar == NSDeleteCharacter || eventChar == NSDeleteFunctionKey) &&
+ BOOL const isLeftRightArrow = eventChar == NSRightArrowFunctionKey || eventChar == NSLeftArrowFunctionKey;
+ BOOL const isUpDownArrow = eventChar == NSUpArrowFunctionKey || eventChar == NSDownArrowFunctionKey;
+ BOOL const isArrow = isLeftRightArrow || isUpDownArrow;
+ BOOL const haveShiftKey = !!(modifiers & NSShiftKeyMask);
+ BOOL const isPageDown = eventChar == NSPageDownFunctionKey || eventChar == ' ' && !haveShiftKey;
+ BOOL const isPageUp = eventChar == NSPageUpFunctionKey || eventChar == ' ' && haveShiftKey;
+
+ if (isPageDown) {
+ [self goToNextPage:self];
+ } else if (isPageUp) {
+ [self goToPreviousPage:self];
+ } else if ((eventChar == NSDeleteCharacter || eventChar == NSDeleteFunctionKey) &&
(modifiers == 0)) {
[self delete:self];
} else if (([self toolMode] == SKTextToolMode || [self toolMode] == SKNoteToolMode) && activeAnnotation && editor == nil &&
Issue: in OS X 10.10 (14A314h), NSKeyDown events for the pagedown key and the space bar result in a call to goToPreviousPage, and pageup/shift-space result in a call to goToNextPage.
I wrote a patch for this (below) but:
- I’m a newbie with Skim’s source code (and Objective-C in general);
- I’m not sure where keyboard bindings are normally supposed to happen; and
- I’m not sure whether this is a bug in Yosemite (though Preview.app seems well behaved).
Criticism welcome!
—James
Index: SKPDFView.m
===================================================================
--- SKPDFView.m (revision 8385)
+++ SKPDFView.m (working copy)
@@ -1045,11 +1045,18 @@
}
} else {
// Normal or fullscreen mode
- BOOL isLeftRightArrow = eventChar == NSRightArrowFunctionKey || eventChar == NSLeftArrowFunctionKey;
- BOOL isUpDownArrow = eventChar == NSUpArrowFunctionKey || eventChar == NSDownArrowFunctionKey;
- BOOL isArrow = isLeftRightArrow || isUpDownArrow;
-
- if ((eventChar == NSDeleteCharacter || eventChar == NSDeleteFunctionKey) &&
+ BOOL const isLeftRightArrow = eventChar == NSRightArrowFunctionKey || eventChar == NSLeftArrowFunctionKey;
+ BOOL const isUpDownArrow = eventChar == NSUpArrowFunctionKey || eventChar == NSDownArrowFunctionKey;
+ BOOL const isArrow = isLeftRightArrow || isUpDownArrow;
+ BOOL const haveShiftKey = !!(modifiers & NSShiftKeyMask);
+ BOOL const isPageDown = eventChar == NSPageDownFunctionKey || eventChar == ' ' && !haveShiftKey;
+ BOOL const isPageUp = eventChar == NSPageUpFunctionKey || eventChar == ' ' && haveShiftKey;
+
+ if (isPageDown) {
+ [self goToNextPage:self];
+ } else if (isPageUp) {
+ [self goToPreviousPage:self];
+ } else if ((eventChar == NSDeleteCharacter || eventChar == NSDeleteFunctionKey) &&
(modifiers == 0)) {
[self delete:self];
} else if (([self toolMode] == SKTextToolMode || [self toolMode] == SKNoteToolMode) && activeAnnotation && editor == nil &&