TCustomTabControl: don't steal foucus in ActivateFirstControlOnPage. Part of issue #40775.

(cherry picked from commit f3aa0586d9)
This commit is contained in:
Bart 2024-02-24 14:33:16 +01:00 committed by Maxim Ganetsky
parent 08788350f6
commit 31e54e32fa

View File

@ -772,13 +772,16 @@ end;
procedure TCustomTabControl.ActivateFirstControlOnPage(APage: TCustomPage);
var
ParentForm: TCustomForm;
C: TWinControl;
C, ActiveControl: 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)]);
ActiveControl := ParentForm.ActiveControl;
//don't steal focus if a control outside is ActiveControl
if (Self = ActiveControl) or Self.ContainsControl(ActiveControl) then
begin
C := APage.FindNextControl(Self, True, True, True);
if Assigned(C) then