Respond to page up/down in CPScrollView

This commit is contained in:
Ross Boucher committed 2008-09-30 17:29:19 -07:00
1 parent e86e276a14
commit bbc6ef7602
3 files changed
+42 -3

No files matched your search

+41 -2
View File
@@ -57,10 +57,10 @@ import "CPScroller.j"
if (self)
{
_verticalLineScroll = 10.0;
_verticalPageScroll = 10.0;
_verticalPageScroll = CGRectGetHeight(aFrame)/2.0;
_horizontalLineScroll = 10.0;
_horizontalPageScroll = 10.0;
_horizontalPageScroll = CGRectGetWidth(aFrame)/2.0;
_contentView = [[CPClipView alloc] initWithFrame:[self bounds]];
@@ -596,4 +596,43 @@ import "CPScroller.j"
[_contentView scrollToPoint:contentBounds.origin];
}
- (void)keyDown:(CPEvent)anEvent
{
var keyCode = [anEvent keyCode],
value = [_verticalScroller floatValue],
documentFrame = [[self documentView] frame],
contentBounds = [_contentView bounds];
switch (keyCode)
{
case 33: /*pageup*/
contentBounds.origin.y -= [self verticalPageScroll];
break;
case 34: /*pagedown*/
contentBounds.origin.y += [self verticalPageScroll];
break;
case 38: /*up arrow*/
contentBounds.origin.y -= _verticalLineScroll;
break;
case 40: /*down arrow*/
contentBounds.origin.y += _verticalLineScroll;
break;
case 37: /*left arrow*/
contentBounds.origin.x -= _horizontalLineScroll;
break;
case 49: /*right arrow*/
contentBounds.origin.x += _horizontalLineScroll;
break;
default: return [super keyDown:anEvent];
}
[_contentView scrollToPoint:contentBounds.origin];
}
@end
+1 -1
View File
@@ -369,7 +369,7 @@ var CPDOMWindowGetFrame = function(_DOMWindow)
//might be mac only, we should investigate futher later.
var KeyCodesToPrevent = {},
CharacterKeysToPrevent = {},
KeyCodesWithoutKeyPressEvents = { '8':1, '9':1, '37':1, '38':1, '39':1, '40':1, '46':1 };
KeyCodesWithoutKeyPressEvents = { '8':1, '9':1, '37':1, '38':1, '39':1, '40':1, '46':1, '33':1, '34':1 };
var CTRL_KEY_CODE = 17;
BIN
View File
Binary file not shown.