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/gui/gui_tab.pas | |
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/gui/gui_tab.pas')
-rw-r--r-- | src/gui/gui_tab.pas | 39 |
1 files changed, 37 insertions, 2 deletions
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); |