mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Closes #528.
Update CPScrollView to use more modern key command parsing.
This commit is contained in:
@@ -28,6 +28,8 @@ CPTabKeyCode = 9;
|
||||
CPReturnKeyCode = 13;
|
||||
CPEscapeKeyCode = 27;
|
||||
CPSpaceKeyCode = 32;
|
||||
CPPageUpKeyCode = 33;
|
||||
CPPageDownKeyCode = 34;
|
||||
CPLeftArrowKeyCode = 37;
|
||||
CPUpArrowKeyCode = 38;
|
||||
CPRightArrowKeyCode = 39;
|
||||
@@ -106,6 +108,10 @@ CPDownArrowKeyCode = 40;
|
||||
|
||||
switch([event keyCode])
|
||||
{
|
||||
case CPPageUpKeyCode: [self doCommandBySelector:@selector(pageUp:)];
|
||||
break;
|
||||
case CPPageDownKeyCode: [self doCommandBySelector:@selector(pageDown:)];
|
||||
break;
|
||||
case CPLeftArrowKeyCode: [self doCommandBySelector:@selector(moveLeft:)];
|
||||
break;
|
||||
case CPRightArrowKeyCode: [self doCommandBySelector:@selector(moveRight:)];
|
||||
|
||||
+40
-30
@@ -683,38 +683,48 @@
|
||||
|
||||
- (void)keyDown:(CPEvent)anEvent
|
||||
{
|
||||
var keyCode = [anEvent keyCode],
|
||||
documentFrame = [[self documentView] frame],
|
||||
[self interpretKeyEvents:[anEvent]];
|
||||
}
|
||||
|
||||
- (void)pageUp:(id)sender
|
||||
{
|
||||
var contentBounds = [_contentView bounds];
|
||||
[self moveByOffset:CGSizeMake(0.0, -(_CGRectGetHeight(contentBounds) - _verticalPageScroll))];
|
||||
}
|
||||
|
||||
- (void)pageDown:(id)sender
|
||||
{
|
||||
var contentBounds = [_contentView bounds];
|
||||
[self moveByOffset:CGSizeMake(0.0, _CGRectGetHeight(contentBounds) - _verticalPageScroll)];
|
||||
}
|
||||
|
||||
- (void)moveLeft:(id)sender
|
||||
{
|
||||
[self moveByOffset:CGSizeMake(-_horizontalLineScroll, 0.0)];
|
||||
}
|
||||
|
||||
- (void)moveRight:(id)sender
|
||||
{
|
||||
[self moveByOffset:CGSizeMake(_horizontalLineScroll, 0.0)];
|
||||
}
|
||||
|
||||
- (void)moveUp:(id)sender
|
||||
{
|
||||
[self moveByOffset:CGSizeMake(0.0, -_verticalLineScroll)];
|
||||
}
|
||||
|
||||
- (void)moveDown:(id)sender
|
||||
{
|
||||
[self moveByOffset:CGSizeMake(0.0, _verticalLineScroll)];
|
||||
}
|
||||
|
||||
- (void)moveByOffset:(CGSize)aSize
|
||||
{
|
||||
var documentFrame = [[self documentView] frame],
|
||||
contentBounds = [_contentView bounds];
|
||||
|
||||
switch (keyCode)
|
||||
{
|
||||
case 33: /*pageup*/
|
||||
contentBounds.origin.y -= _CGRectGetHeight(contentBounds) - _verticalPageScroll;
|
||||
break;
|
||||
|
||||
case 34: /*pagedown*/
|
||||
contentBounds.origin.y += _CGRectGetHeight(contentBounds) - _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];
|
||||
}
|
||||
contentBounds.origin.x += aSize.width;
|
||||
contentBounds.origin.y += aSize.height;
|
||||
|
||||
[_contentView scrollToPoint:contentBounds.origin];
|
||||
[_headerClipView scrollToPoint:CGPointMake(contentBounds.origin, 0)];
|
||||
|
||||
Reference in New Issue
Block a user