mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-28 04:51:34 +01: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
|
Makes sure Visible = true for page which has index FPageIndex
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TCustomTabControl.ShowCurrentPage;
|
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
|
var
|
||||||
CurPage: TCustomPage;
|
CurPage: TCustomPage;
|
||||||
begin
|
begin
|
||||||
|
CurPage := nil;
|
||||||
if (FPageIndex >= 0) and (FPageIndex < PageCount) then
|
if (FPageIndex >= 0) and (FPageIndex < PageCount) then
|
||||||
begin
|
begin
|
||||||
CurPage := Page[FPageIndex];
|
CurPage := Page[FPageIndex];
|
||||||
@ -1147,6 +1162,8 @@ begin
|
|||||||
if (FPageIndexOnLastChange >= 0) and (FPageIndexOnLastChange < PageCount) and
|
if (FPageIndexOnLastChange >= 0) and (FPageIndexOnLastChange < PageCount) and
|
||||||
(FPageIndexOnLastChange <> FPageIndex) then
|
(FPageIndexOnLastChange <> FPageIndex) then
|
||||||
begin
|
begin
|
||||||
|
if Assigned(CurPage) and HasFocusedControl(Page[FPageIndexOnLastChange]) then
|
||||||
|
CurPage.SetFocus;
|
||||||
Page[FPageIndexOnLastChange].Visible := False;
|
Page[FPageIndexOnLastChange].Visible := False;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user