mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 16:38:17 +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;
|
function GetPageCount : integer; virtual;
|
||||||
procedure InsertPage(APage: TCustomPage; Index: Integer); virtual;
|
procedure InsertPage(APage: TCustomPage; Index: Integer); virtual;
|
||||||
procedure RemovePage(Index: Integer); virtual;
|
procedure RemovePage(Index: Integer); virtual;
|
||||||
|
procedure ActivateFirstControlOnPage(APage: TCustomPage) virtual;
|
||||||
//Delphi compatible properties
|
//Delphi compatible properties
|
||||||
function CanChange: Boolean; virtual;
|
function CanChange: Boolean; virtual;
|
||||||
property DisplayRect: TRect read GetDisplayRect;
|
property DisplayRect: TRect read GetDisplayRect;
|
||||||
|
@ -769,6 +769,23 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
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;
|
function TCustomTabControl.IsStoredActivePage: boolean;
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
@ -1028,12 +1045,27 @@ end;
|
|||||||
TCustomTabControl Change
|
TCustomTabControl Change
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TCustomTabControl.Change;
|
procedure TCustomTabControl.Change;
|
||||||
|
var
|
||||||
|
APage: TCustomPage;
|
||||||
|
ParentForm: TCustomForm;
|
||||||
|
ActiveControl: TWinControl;
|
||||||
begin
|
begin
|
||||||
//DebugLn(['TCustomTabControl.Change ',DbgSName(Self),' fPageIndex=',fPageIndex]);
|
//DebugLn(['TCustomTabControl.Change ',DbgSName(Self),' fPageIndex=',fPageIndex]);
|
||||||
ShowCurrentPage;
|
ShowCurrentPage;
|
||||||
FPageIndexOnLastChange := FPageIndex;
|
FPageIndexOnLastChange := FPageIndex;
|
||||||
|
|
||||||
if ([csLoading,csDestroying]*ComponentState=[]) and (not FAddingPages) then
|
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;
|
DoChange;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomTabControl.DialogChar(var Message: TLMKey): boolean;
|
function TCustomTabControl.DialogChar(var Message: TLMKey): boolean;
|
||||||
@ -1069,6 +1101,7 @@ begin
|
|||||||
FPageIndex := AValue;
|
FPageIndex := AValue;
|
||||||
UpdateAllDesignerFlags;
|
UpdateAllDesignerFlags;
|
||||||
DoSendPageIndex;
|
DoSendPageIndex;
|
||||||
|
ActivateFirstControlOnPage(GetActivePageComponent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
@ -116,6 +116,8 @@ begin
|
|||||||
if Widgetset.GetLCLCapability(lcAllowChildControlsInNativeControls) = LCL_CAPABILITY_YES then Result := True;
|
if Widgetset.GetLCLCapability(lcAllowChildControlsInNativeControls) = LCL_CAPABILITY_YES then Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function TPageControl.FindNextPage(CurPage: TTabSheet; GoForward,
|
function TPageControl.FindNextPage(CurPage: TTabSheet; GoForward,
|
||||||
CheckTabVisible: Boolean): TTabSheet;
|
CheckTabVisible: Boolean): TTabSheet;
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user