diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-03 15:32:39 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-03 15:32:39 +0000 |
commit | b1c2f18463febac4c3945aa7c92ac8c3ff366ce9 (patch) | |
tree | ef547c317bf9755c5076c60e66ee057a2160cf87 /src | |
parent | ec379abe306e8361bf5902c5e20cee66f82ee682 (diff) | |
download | fpGUI-b1c2f18463febac4c3945aa7c92ac8c3ff366ce9.tar.xz |
* Implemented basic keyboard navigation for PageControl. It needs more testing and tweaking though.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/gui_edit.pas | 9 | ||||
-rw-r--r-- | src/gui/gui_tab.pas | 39 |
2 files changed, 45 insertions, 3 deletions
diff --git a/src/gui/gui_edit.pas b/src/gui/gui_edit.pas index 2f1ee216..c6820a5e 100644 --- a/src/gui/gui_edit.pas +++ b/src/gui/gui_edit.pas @@ -290,7 +290,9 @@ end; procedure TfpgEdit.HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); - +var + lpos: integer; + procedure StopSelection; begin FSelStart := FCursorPos; @@ -298,7 +300,9 @@ procedure TfpgEdit.HandleKeyPress(var keycode: word; end; begin +// writeln(Classname, '.Keypress'); Consumed := False; + lpos := FCursorPos; { Consumed := true; case ptkCheckClipBoardKey(keycode, shiftstate) of @@ -357,6 +361,9 @@ begin Consumed := False; end; + if lpos = FCursorPos then // nothing changed so reset consumed + consumed := False; + if Consumed then begin AdjustCursor; diff --git a/src/gui/gui_tab.pas b/src/gui/gui_tab.pas index efe01a85..5750cad3 100644 --- a/src/gui/gui_tab.pas +++ b/src/gui/gui_tab.pas @@ -91,6 +91,7 @@ type procedure RePaintTitles; virtual; procedure HandlePaint; override; procedure HandleLMouseUp(x, y: integer; shiftstate: TShiftState); override; + procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -343,7 +344,6 @@ begin if FFirstTabButton <> nil then begin if TfpgTabSheet(FPages.First) <> FFirstTabButton then -// if FPages.IndexOf(FFirstTabButton) <> 0 then begin FFirstTabButton := TfpgTabSheet(FPages[FPages.IndexOf(FFirstTabButton)-1]); RePaint; @@ -357,7 +357,6 @@ begin if FFirstTabButton <> nil then begin if TfpgTabSheet(FPages.Last) <> FFirstTabButton then -// if FPages.IndexOf(FFirstTabButton) <> (FPages.Count-1) then begin FFirstTabButton := TfpgTabSheet(FPages[FPages.IndexOf(FFirstTabButton)+1]); RePaint; @@ -595,6 +594,42 @@ begin inherited HandleLMouseUp(x, y, shiftstate); end; +procedure TfpgPageControl.HandleKeyPress(var keycode: word; + var shiftstate: TShiftState; var consumed: boolean); +var + t: TfpgTabSheet; + i: integer; +begin +// writeln(Classname, '.Keypress'); + consumed := True; + i := ActivePageIndex; + t := ActivePage; + + case keycode of + keyLeft: + begin + if ActivePage <> TfpgTabSheet(FPages.First) then + begin + ActivePage := TfpgTabSheet(FPages[i-1]); + DoChange(ActivePage); + end; + end; + + keyRight: + begin + if ActivePage <> TfpgTabSheet(FPages.Last) then + begin + ActivePage := TfpgTabSheet(FPages[i+1]); + DoChange(ActivePage); + end; + end; + + else + consumed := False; + end; { case/else } + inherited HandleKeyPress(keycode, shiftstate, consumed); +end; + constructor TfpgPageControl.Create(AOwner: TComponent); begin inherited Create(AOwner); |