mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 18:37:58 +02:00
TCustomTabControl: activate first control on page after page changed. Issue #40775.
This commit is contained in:
parent
b0bb460a46
commit
e5a637999d
@ -463,6 +463,7 @@ type
|
||||
function GetPageCount : integer; virtual;
|
||||
procedure InsertPage(APage: TCustomPage; Index: Integer); virtual;
|
||||
procedure RemovePage(Index: Integer); virtual;
|
||||
procedure ActivateFirstControlOnPage(APage: TCustomPage) virtual;
|
||||
//Delphi compatible properties
|
||||
function CanChange: Boolean; virtual;
|
||||
property DisplayRect: TRect read GetDisplayRect;
|
||||
|
@ -769,6 +769,23 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TCustomTabControl.ActivateFirstControlOnPage(APage: TCustomPage);
|
||||
var
|
||||
ParentForm: TCustomForm;
|
||||
C: TWinControl;
|
||||
begin
|
||||
ParentForm := GetParentForm(Self);
|
||||
//Debugln(['TCustomTabControl.ActivateFirstControl: Self=',DbgSName(Self),', APage=',DbgSName(APage),', ParentForm=',DbgSName(ParentForm)]);
|
||||
if not (Assigned(APage) and Assigned(ParentForm) and APage.Visible and APage.Enabled and (APage.ControlCount > 0)) then
|
||||
Exit;
|
||||
//Debugln(['TCustomTabControl.ActivateFirstControl: APage.Visible=',APage.Visible,', APage.Enabled=',APage.Enabled,', (APage.ControlCount > 0)=', (APage.ControlCount > 0)]);
|
||||
begin
|
||||
C := APage.FindNextControl(Self, True, True, True);
|
||||
if Assigned(C) then
|
||||
ParentForm.ActiveControl := C;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function TCustomTabControl.IsStoredActivePage: boolean;
|
||||
------------------------------------------------------------------------------}
|
||||
@ -1028,12 +1045,27 @@ end;
|
||||
TCustomTabControl Change
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomTabControl.Change;
|
||||
var
|
||||
APage: TCustomPage;
|
||||
ParentForm: TCustomForm;
|
||||
ActiveControl: TWinControl;
|
||||
begin
|
||||
//DebugLn(['TCustomTabControl.Change ',DbgSName(Self),' fPageIndex=',fPageIndex]);
|
||||
ShowCurrentPage;
|
||||
FPageIndexOnLastChange := FPageIndex;
|
||||
|
||||
if ([csLoading,csDestroying]*ComponentState=[]) and (not FAddingPages) then
|
||||
begin
|
||||
APage := ActivePageComponent;
|
||||
//debugln(['TCustomTabControl.Change: Self=',DbgSName(Self),', APage',DbgSName(APage)]);
|
||||
//if Assigned(APage) then debugln(['APage.Visible=',APage.Visible,', APage.Enabled=',APage.Enabled,', (APage.ControlCount > 0)=',(APage.ControlCount > 0)]);
|
||||
ParentForm := GetParentForm(Self);
|
||||
if not (Assigned(ParentForm) and Assigned(APage) and APage.Visible and APage.Enabled and (APage.ControlCount > 0)) then
|
||||
Exit;
|
||||
ActivateFirstControlOnPage(APage);
|
||||
|
||||
DoChange;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCustomTabControl.DialogChar(var Message: TLMKey): boolean;
|
||||
@ -1069,6 +1101,7 @@ begin
|
||||
FPageIndex := AValue;
|
||||
UpdateAllDesignerFlags;
|
||||
DoSendPageIndex;
|
||||
ActivateFirstControlOnPage(GetActivePageComponent);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
@ -116,6 +116,8 @@ begin
|
||||
if Widgetset.GetLCLCapability(lcAllowChildControlsInNativeControls) = LCL_CAPABILITY_YES then Result := True;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function TPageControl.FindNextPage(CurPage: TTabSheet; GoForward,
|
||||
CheckTabVisible: Boolean): TTabSheet;
|
||||
var
|
||||
|
Loading…
Reference in New Issue
Block a user