From 07aaf033e8d587bf64319c2d35aba108955dde1a Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Sat, 12 Jun 2010 13:34:02 +0200 Subject: TextEdit: keeps scrollbar position in sync when using Up/Down arrow keys... ...to scroll text. --- prototypes/textedit/fpg_textedit.pas | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'prototypes/textedit') diff --git a/prototypes/textedit/fpg_textedit.pas b/prototypes/textedit/fpg_textedit.pas index 0adfb821..f1ac2b00 100644 --- a/prototypes/textedit/fpg_textedit.pas +++ b/prototypes/textedit/fpg_textedit.pas @@ -807,6 +807,9 @@ begin if not (ssShift in ShiftState) and not (ssCtrl in ShiftState) then begin CaretPos.Y := CaretPos.Y - 1; + // scroll text + if FVScrollBar.Visible and (CaretPos.Y < FTopLine) then + FVScrollBar.LineUp; if FSelected then begin FSelected := False; @@ -850,7 +853,10 @@ begin if not (ssShift in ShiftState) and not (ssCtrl in ShiftState) then begin CaretPos.Y := CaretPos.Y + 1; - if FSelected then + // scroll text + if FVScrollBar.Visible and (CaretPos.Y > FTopLine+FVisLines-2) then + FVScrollBar.LineDown; + if FSelected then begin FSelected := False; Exit; @@ -1307,13 +1313,12 @@ begin else if CaretPos.X < HPos then ScrollPos_H := CaretPos.X; - if CaretPos.Y < FTopLine then + if CaretPos.Y < (FTopLine+1) then ScrollPos_V := CaretPos.Y - else if CaretPos.Y > FTopLine + FVisLines - 2 then + else if CaretPos.Y > (FTopLine + FVisLines - 2) then ScrollPos_V := CaretPos.Y - FVisLines + 2; Invalidate; - writeln('<< TfpgBaseTextEdit.HandleKeyPress'); end; procedure TfpgBaseTextEdit.HandleKeyChar(var AText: TfpgChar; -- cgit v1.2.3-70-g09d2