Patch from bug #19750: TCustomNotebook: Allow keyboard tab switching

git-svn-id: trunk@31733 -
This commit is contained in:
sekelsenmat 2011-07-18 12:50:40 +00:00
parent 53de325aa6
commit 66231a14fe
2 changed files with 23 additions and 1 deletions

View File

@ -297,7 +297,9 @@ type
TTabGetImageEvent = procedure(Sender: TObject; TabIndex: Integer;
var ImageIndex: Integer) of object;
TNoteBookOption = (nboShowCloseButtons, nboMultiLine, nboHidePageListPopup);
TNoteBookOption = (
nboShowCloseButtons, nboMultiLine, nboHidePageListPopup,
nboKeyboardTabSwitch);
TNoteBookOptions = set of TNoteBookOption;
TNoteBookCapability = (nbcShowCloseButtons, nbcMultiLine, nbcPageListPopup);
TNoteBookCapabilities = set of TNoteBookCapability;
@ -366,6 +368,7 @@ type
procedure DoCreateWnd; virtual;
procedure DoChange; virtual;
procedure Change; virtual;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure Loaded; override;
procedure ReadState(Reader: TReader); override;
function DialogChar(var Message: TLMKey): boolean; override;

View File

@ -724,6 +724,25 @@ begin
Result:=false;
end;
procedure TCustomNotebook.KeyDown(var Key: Word; Shift: TShiftState);
begin
if (nboKeyboardTabSwitch in Options) and (Key = VK_TAB) and (PageCount > 0) then
begin
if Shift = [ssCtrl] then
begin
PageIndex := (PageIndex + 1) mod PageCount;
Exit;
end
else if Shift = [ssCtrl, ssShift] then
begin
PageIndex := (PageIndex + PageCount - 1) mod PageCount;
Exit;
end;
end;
inherited KeyDown(Key, Shift);
end;
{------------------------------------------------------------------------------
TCustomNotebook GetPageCount
------------------------------------------------------------------------------}