Implement CPScrollView scrollToBeginningOfDocument: and scrollToEndOfDocument:.

Also ensures that the home/end DOM keys were properly mapped to their Cocoa equivalents, so that home/end will trigger scrollToBeginningOfDocument:/scrollToEndOfDocument:.
This commit is contained in:
Brian Donovan
2010-12-14 12:12:25 -08:00
parent 003dcface0
commit 9bf0edb5df
2 changed files with 23 additions and 2 deletions
+21 -2
View File
@@ -974,6 +974,20 @@
[self moveByOffset:CGSizeMake(0.0, _CGRectGetHeight(contentBounds) - _verticalPageScroll)];
}
- (void)scrollToBeginningOfDocument:(id)sender
{
var contentBounds = [_contentView bounds];
[self _moveToPoint:_CGPointMakeZero()];
}
- (void)scrollToEndOfDocument:(id)sender
{
var contentBounds = [_contentView bounds],
documentFrame = [[self documentView] frame];
[self _moveToPoint:_CGPointMake(0.0, _CGRectGetHeight(documentFrame) - _CGRectGetHeight(contentBounds))]
}
- (void)moveLeft:(id)sender
{
[self moveByOffset:CGSizeMake(-_horizontalLineScroll, 0.0)];
@@ -1002,8 +1016,13 @@
contentBounds.origin.x += aSize.width;
contentBounds.origin.y += aSize.height;
[_contentView scrollToPoint:contentBounds.origin];
[_headerClipView scrollToPoint:CGPointMake(contentBounds.origin, 0)];
[self _moveToPoint:contentBounds.origin];
}
- (void)_moveToPoint:(CGPoint)aPoint
{
[_contentView scrollToPoint:aPoint];
[_headerClipView scrollToPoint:CGPointMake(aPoint, 0)];
}
@end
@@ -168,6 +168,8 @@ KeyCodesToUnicodeMap[CPKeyCodes.LEFT] = CPLeftArrowFunctionKey
KeyCodesToUnicodeMap[CPKeyCodes.UP] = CPUpArrowFunctionKey;
KeyCodesToUnicodeMap[CPKeyCodes.RIGHT] = CPRightArrowFunctionKey;
KeyCodesToUnicodeMap[CPKeyCodes.DOWN] = CPDownArrowFunctionKey;
KeyCodesToUnicodeMap[CPKeyCodes.HOME] = CPHomeFunctionKey;
KeyCodesToUnicodeMap[CPKeyCodes.END] = CPEndFunctionKey;
KeyCodesToUnicodeMap[CPKeyCodes.SEMICOLON] = ";";
KeyCodesToUnicodeMap[CPKeyCodes.DASH] = "-";
KeyCodesToUnicodeMap[CPKeyCodes.EQUALS] = "=";