diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2010-06-11 23:47:42 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2010-06-11 23:47:42 +0200 |
commit | 6d6d9a68f5bb8913b6e430e6c32e7781daf0ae4a (patch) | |
tree | afea97f57c6d22505a933e825787961db42e5f67 /prototypes/textedit | |
parent | 21b3e2e6dbb3b643d43d5078276639b77374b671 (diff) | |
download | fpGUI-6d6d9a68f5bb8913b6e430e6c32e7781daf0ae4a.tar.xz |
TextEdit: implemented PgUp and PgDn key support.
Diffstat (limited to 'prototypes/textedit')
-rw-r--r-- | prototypes/textedit/fpg_textedit.pas | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/prototypes/textedit/fpg_textedit.pas b/prototypes/textedit/fpg_textedit.pas index 8346ce3d..ee1a8cc1 100644 --- a/prototypes/textedit/fpg_textedit.pas +++ b/prototypes/textedit/fpg_textedit.pas @@ -188,7 +188,7 @@ type implementation uses - fpg_dialogs{, fpg_constants}, fpg_stringutils, fpg_utils; + fpg_dialogs{, fpg_constants}, fpg_stringutils, fpg_utils, math; function GetNextWord(SLine: TfpgString; var PosX: Integer): Boolean; @@ -617,6 +617,8 @@ end; { This procedure is used to set caret position on keyboard navigation and to set selection if Shift key is pressed. } procedure TfpgBaseTextEdit.KeyboardCaretNav(const ShiftState: TShiftState; const AKeyCode: Word); +var + SaveXCaret: Integer; procedure CtrlKeyLeftKey; var @@ -674,7 +676,6 @@ procedure TfpgBaseTextEdit.KeyboardCaretNav(const ShiftState: TShiftState; const end; begin - writeln('DEBUG: TfpgBaseTextEdit.KeyboardCaretNav >>'); case AKeyCode of keyLeft: begin @@ -986,11 +987,55 @@ begin end; end; - keyPrior, keyNext: + keyPageUp, keyPageDown: begin + if not FSelected then + begin + FSelStartNo := CaretPos.Y; + FSelStartOffs := CaretPos.X; + end; + SaveXCaret := CaretPos.Y - FTopLine; + if AKeyCode = keyPageUp then + begin + if VPos = 0 then + begin + CaretPos.Y := 0; + CaretPos.X := 0; + end + else + begin + // scroll text + if FVScrollBar.Visible then + FVScrollBar.PageUp; + // restore caret at same line offset as before + CaretPos.Y := FTopLine + SaveXCaret; + end; + end + else + begin + if VPos > (FLines.Count - FVisLines) then + begin + CaretPos.Y := FLines.Count-1; + CaretPos.X := Length(FLines[CaretPos.Y]); + end + else + begin + // scroll text + if FVScrollBar.Visible then + FVScrollBar.PageDown; + // restore caret at same line offset as before + CaretPos.Y := FTopLine + SaveXCaret; + end; + end; + if ssShift in ShiftState then + begin + FSelEndNo := CaretPos.Y; + FSelEndOffs := CaretPos.X; + if not FSelected then + FSelected := True; + end; end; end; - writeln('DEBUG: TfpgBaseTextEdit.KeyboardCaretNav <<'); end; procedure TfpgBaseTextEdit.InitMemoObjects; |