mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 10:33:36 +02:00
LCL: PageControl, fixed active page should not change (same tabsheet, may be at new index) if moving pages
git-svn-id: trunk@42680 -
This commit is contained in:
parent
01192bcac9
commit
ae2989ecac
@ -174,9 +174,16 @@ procedure TNBPages.Move(CurIndex, NewIndex: Integer);
|
|||||||
var
|
var
|
||||||
APage: TCustomPage;
|
APage: TCustomPage;
|
||||||
NewControlIndex, NewPageIndex: integer;
|
NewControlIndex, NewPageIndex: integer;
|
||||||
|
ActivePageIndex: Integer;
|
||||||
|
ActivePage: TCustomPage;
|
||||||
begin
|
begin
|
||||||
if CurIndex = NewIndex then Exit;
|
if CurIndex = NewIndex then Exit;
|
||||||
NewPageIndex := NewIndex;
|
ActivePageIndex := FNotebook.PageIndex;
|
||||||
|
if (FNotebook.PageIndex >= 0) and (FNotebook.PageIndex < Count) then
|
||||||
|
ActivePage := GetPage(ActivePageIndex)
|
||||||
|
else
|
||||||
|
ActivePage := nil;
|
||||||
|
//NewPageIndex := NewIndex;
|
||||||
|
|
||||||
APage := TCustomPage(FPageList[CurIndex]);
|
APage := TCustomPage(FPageList[CurIndex]);
|
||||||
|
|
||||||
@ -186,21 +193,6 @@ begin
|
|||||||
else
|
else
|
||||||
NewControlIndex := FNotebook.GetControlIndex(TCustomPage(FPageList[NewIndex]));
|
NewControlIndex := FNotebook.GetControlIndex(TCustomPage(FPageList[NewIndex]));
|
||||||
|
|
||||||
// calculate new PageIndex
|
|
||||||
if FNotebook.PageIndex = CurIndex then
|
|
||||||
NewPageIndex := NewIndex
|
|
||||||
else
|
|
||||||
if FNotebook.PageIndex > CurIndex then
|
|
||||||
begin
|
|
||||||
if FNotebook.PageIndex <= NewIndex then
|
|
||||||
NewPageIndex := FNotebook.PageIndex - 1;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
if FNotebook.PageIndex >= NewIndex then
|
|
||||||
NewPageIndex := FNotebook.PageIndex + 1;
|
|
||||||
end;
|
|
||||||
|
|
||||||
FNotebook.DisableAutoSizing;
|
FNotebook.DisableAutoSizing;
|
||||||
try
|
try
|
||||||
// move Page in notebook handle
|
// move Page in notebook handle
|
||||||
@ -213,7 +205,11 @@ begin
|
|||||||
FNotebook.SetControlIndex(APage, NewControlIndex);
|
FNotebook.SetControlIndex(APage, NewControlIndex);
|
||||||
|
|
||||||
// update PageIndex
|
// update PageIndex
|
||||||
FNotebook.PageIndex := NewPageIndex;
|
if ActivePage <> nil then
|
||||||
|
FNotebook.PageIndex := IndexOfPage(ActivePage)
|
||||||
|
else // Can not restore an invalid page index.
|
||||||
|
if FNotebook.PageIndex >= 0 then // keep if -1
|
||||||
|
FNotebook.PageIndex := NewIndex;
|
||||||
finally
|
finally
|
||||||
FNotebook.EnableAutoSizing;
|
FNotebook.EnableAutoSizing;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user