mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +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
d4fe1a2399
commit
3a4a94238e
4 changed files with 111 additions and 16 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2007-02-28 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSScrollView.m (-keyDown:, -scrollLineUp:,
|
||||
-scrollLineDown:): New methods.
|
||||
* Source/NSTextView_actions.m (-scrollLineDown:, -scrollLineUp:,
|
||||
-scrollPageDown:, -scrollPageUp:): Implement methods based on
|
||||
scroll view.
|
||||
* KeyBindings/DefaultKeyBindings.dict: Change control-up and and
|
||||
page up to be scrollPageUp: and control-down and page down to be
|
||||
scrollPageDown:. pageDown: and pageUp: can now be reached via
|
||||
control-pageup and alt-pageup resp. control-pagedown and alt-pagedown.
|
||||
Patch by Wolfgang Lux <wolfgang.lux@gmail.com>.
|
||||
|
||||
2007-02-28 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/AppKit/NSScrollView.h: Add ivar
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
"LeftArrow" = "moveLeft:";
|
||||
"RightArrow" = "moveRight:";
|
||||
|
||||
"Control-UpArrow" = "pageUp:";
|
||||
"Control-DownArrow" = "pageDown:";
|
||||
"Control-UpArrow" = "scrollPageUp:";
|
||||
"Control-DownArrow" = "scrollPageDown:";
|
||||
"Control-LeftArrow" = "moveToBeginningOfLine:";
|
||||
"Control-RightArrow" = "moveToEndOfLine:";
|
||||
|
||||
|
@ -43,12 +43,18 @@
|
|||
"End" = "moveToEndOfParagraph:";
|
||||
"Control-End" = "moveToEndOfDocument:";
|
||||
/* "Shift-End" = "moveToEndOfParagraphAndModifySelection:"; */
|
||||
"PageUp" = "pageUp:";
|
||||
"PageDown" = "pageDown:";
|
||||
"PageUp" = "scrollPageUp:";
|
||||
"PageDown" = "scrollPageDown:";
|
||||
|
||||
"Shift-PageDown" = "pageDownAndModifySelection:";
|
||||
"Shift-PageUp" = "pageUpAndModifySelection:";
|
||||
|
||||
"Control-PageDown" = "pageDown:";
|
||||
"Control-PageUp" = "pageUp:";
|
||||
|
||||
"Alternate-PageDown" = "pageDown:";
|
||||
"Alternate-PageUp" = "pageUp:";
|
||||
|
||||
/* Emacs Control keybindings */
|
||||
"Control-a" = "moveToBeginningOfLine:";
|
||||
"Control-b" = "moveBackward:";
|
||||
|
|
|
@ -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:
|
||||
*/
|
||||
|
|
|
@ -1302,30 +1302,22 @@ and layout is left-to-right */
|
|||
|
||||
- (void) scrollLineDown: (id)sender
|
||||
{
|
||||
// TODO
|
||||
NSLog(@"Method %s is not implemented for class %s",
|
||||
"scrollLineDown:", "NSTextView");
|
||||
[[self enclosingScrollView] scrollLineDown: sender];
|
||||
}
|
||||
|
||||
- (void) scrollLineUp: (id)sender
|
||||
{
|
||||
// TODO
|
||||
NSLog(@"Method %s is not implemented for class %s",
|
||||
"scrollLineUp:", "NSTextView");
|
||||
[[self enclosingScrollView] scrollLineUp: sender];
|
||||
}
|
||||
|
||||
- (void) scrollPageDown: (id)sender
|
||||
{
|
||||
// TODO
|
||||
NSLog(@"Method %s is not implemented for class %s",
|
||||
"scrollPageDown:", "NSTextView");
|
||||
[[self enclosingScrollView] scrollPageDown: sender];
|
||||
}
|
||||
|
||||
- (void) scrollPageUp: (id)sender
|
||||
{
|
||||
// TODO
|
||||
NSLog(@"Method %s is not implemented for class %s",
|
||||
"scrollPageUp:", "NSTextView");
|
||||
[[self enclosingScrollView] scrollPageUp: sender];
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue