mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-24 15:12:23 +02:00
LCL: TPageControl: Focus first control on page when page is changed and a control on it was focused. Issue #33991
git-svn-id: trunk@59186 -
This commit is contained in:
parent
a4503bccc0
commit
8d0fe522bb
@ -1135,9 +1135,24 @@ end;
|
||||
Makes sure Visible = true for page which has index FPageIndex
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomTabControl.ShowCurrentPage;
|
||||
|
||||
function HasFocusedControl(APage: TCustomPage): Boolean;
|
||||
var
|
||||
i: Integer;
|
||||
lForm: TCustomForm;
|
||||
begin
|
||||
Result := False;
|
||||
lForm := GetParentForm(APage);
|
||||
if not Assigned(lForm) then Exit;
|
||||
for i := 0 to APage.ControlCount - 1 do
|
||||
if APage.Controls[i] = lForm.ActiveControl then
|
||||
Exit(True);
|
||||
end;
|
||||
|
||||
var
|
||||
CurPage: TCustomPage;
|
||||
begin
|
||||
CurPage := nil;
|
||||
if (FPageIndex >= 0) and (FPageIndex < PageCount) then
|
||||
begin
|
||||
CurPage := Page[FPageIndex];
|
||||
@ -1147,6 +1162,8 @@ begin
|
||||
if (FPageIndexOnLastChange >= 0) and (FPageIndexOnLastChange < PageCount) and
|
||||
(FPageIndexOnLastChange <> FPageIndex) then
|
||||
begin
|
||||
if Assigned(CurPage) and HasFocusedControl(Page[FPageIndexOnLastChange]) then
|
||||
CurPage.SetFocus;
|
||||
Page[FPageIndexOnLastChange].Visible := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user