mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 15:20:38 +00:00
Add scroll page up and down methods to NSTextView and NSScrollView.
Patch by Wolfgang Lux <wolfgang.lux@gmail.com>. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24732 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
40480d8c22
commit
23a0abf1a3
4 changed files with 111 additions and 16 deletions
|
@ -400,6 +400,90 @@ static float scrollerWidth;
|
|||
[_contentView scrollToPoint: point];
|
||||
}
|
||||
|
||||
- (void) keyDown: (NSEvent *)theEvent
|
||||
{
|
||||
NSString *chars = [theEvent characters];
|
||||
unichar c = [chars length] == 1 ? [chars characterAtIndex: 0] : '\0';
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case NSUpArrowFunctionKey:
|
||||
[self scrollLineUp: self];
|
||||
break;
|
||||
|
||||
case NSDownArrowFunctionKey:
|
||||
[self scrollLineDown: self];
|
||||
break;
|
||||
|
||||
case NSPageUpFunctionKey:
|
||||
[self scrollPageUp: self];
|
||||
break;
|
||||
|
||||
case NSPageDownFunctionKey:
|
||||
[self scrollPageDown: self];
|
||||
break;
|
||||
|
||||
default:
|
||||
[super keyDown: theEvent];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This code is based on _doScroll: and still may need some tuning.
|
||||
*/
|
||||
- (void) scrollLineUp: (id)sender
|
||||
{
|
||||
NSRect clipViewBounds;
|
||||
NSPoint point;
|
||||
float amount;
|
||||
|
||||
if (_contentView == nil)
|
||||
{
|
||||
clipViewBounds = NSZeroRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
clipViewBounds = [_contentView bounds];
|
||||
}
|
||||
point = clipViewBounds.origin;
|
||||
amount = _vLineScroll;
|
||||
if (_contentView != nil && !_contentView->_rFlags.flipped_view)
|
||||
{
|
||||
amount = -amount;
|
||||
}
|
||||
point.y = clipViewBounds.origin.y - amount;
|
||||
[_contentView scrollToPoint: point];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This code is based on _doScroll: and still may need some tuning.
|
||||
*/
|
||||
- (void) scrollLineDown: (id)sender
|
||||
{
|
||||
NSRect clipViewBounds;
|
||||
NSPoint point;
|
||||
float amount;
|
||||
|
||||
if (_contentView == nil)
|
||||
{
|
||||
clipViewBounds = NSZeroRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
clipViewBounds = [_contentView bounds];
|
||||
}
|
||||
point = clipViewBounds.origin;
|
||||
amount = _vLineScroll;
|
||||
if (_contentView != nil && !_contentView->_rFlags.flipped_view)
|
||||
{
|
||||
amount = -amount;
|
||||
}
|
||||
point.y = clipViewBounds.origin.y + amount;
|
||||
[_contentView scrollToPoint: point];
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls the receiver by simply invoking scrollPageUp:
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue