Skip to content

Commit

Permalink
Respond to page up/down in CPScrollView
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Boucher committed Oct 1, 2008
1 parent e86e276 commit bbc6ef7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
43 changes: 41 additions & 2 deletions AppKit/CPScrollView.j
Expand Up @@ -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]];

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion AppKit/Platform/DOM/CPDOMWindowBridge.j
Expand Up @@ -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;

Expand Down
Binary file added AppKit/Resources/.DS_Store
Binary file not shown.

0 comments on commit bbc6ef7

Please sign in to comment.