diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2010-06-12 13:34:02 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2010-06-12 13:34:02 +0200 |
commit | 07aaf033e8d587bf64319c2d35aba108955dde1a (patch) | |
tree | 01182071ecc9b9adde7ecb62bcee83f18e07d3a7 /prototypes/textedit | |
parent | c360255b3d0dd5a67b8d1f5d860656b3d4927400 (diff) | |
download | fpGUI-07aaf033e8d587bf64319c2d35aba108955dde1a.tar.xz |
TextEdit: keeps scrollbar position in sync when using Up/Down arrow keys...
...to scroll text.
Diffstat (limited to 'prototypes/textedit')
-rw-r--r-- | prototypes/textedit/fpg_textedit.pas | 13 |
1 files changed, 9 insertions, 4 deletions
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; |