mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 03:59:13 +02:00
Cocoa/TabControl: improve Robustness
This commit is contained in:
parent
917e9d3ae8
commit
1666b45e46
@ -281,6 +281,8 @@ begin
|
|||||||
if aview.fulltabs.count=0 then exit;
|
if aview.fulltabs.count=0 then exit;
|
||||||
|
|
||||||
tryToKeepIndex:= aview.currentIndex - aview.leftKeepAmount;
|
tryToKeepIndex:= aview.currentIndex - aview.leftKeepAmount;
|
||||||
|
if tryToKeepIndex < 0 then
|
||||||
|
tryToKeepIndex:= 0;
|
||||||
|
|
||||||
// AttachAllTabs() has been modified to not remove the selectedTabViewItem first,
|
// AttachAllTabs() has been modified to not remove the selectedTabViewItem first,
|
||||||
// and no longer trigger tabView_didSelectTabViewItem
|
// and no longer trigger tabView_didSelectTabViewItem
|
||||||
@ -817,10 +819,13 @@ begin
|
|||||||
if fulltabs.count=0 then
|
if fulltabs.count=0 then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
|
OldIndex := exttabIndexOfTabViewItem( lTabPage );
|
||||||
|
if OldIndex < 0 then
|
||||||
|
Exit;
|
||||||
|
|
||||||
if NewIndex > fulltabs.count then
|
if NewIndex > fulltabs.count then
|
||||||
NewIndex:= fulltabs.count;
|
NewIndex:= fulltabs.count;
|
||||||
|
|
||||||
OldIndex := exttabIndexOfTabViewItem( lTabPage );
|
|
||||||
isMovingCurrentPage := (OldIndex=currentIndex);
|
isMovingCurrentPage := (OldIndex=currentIndex);
|
||||||
|
|
||||||
fulltabs.removeObjectAtIndex( OldIndex );
|
fulltabs.removeObjectAtIndex( OldIndex );
|
||||||
@ -861,6 +866,8 @@ begin
|
|||||||
triggeringByLCL:= true;
|
triggeringByLCL:= true;
|
||||||
try
|
try
|
||||||
removedIndex := exttabIndexOfTabViewItem( removedTabPage );
|
removedIndex := exttabIndexOfTabViewItem( removedTabPage );
|
||||||
|
if removedIndex < 0 then
|
||||||
|
Exit;
|
||||||
isRemovingCurrentPage:= (removedIndex=currentIndex);
|
isRemovingCurrentPage:= (removedIndex=currentIndex);
|
||||||
|
|
||||||
fulltabs.removeObjectAtIndex( removedIndex );
|
fulltabs.removeObjectAtIndex( removedIndex );
|
||||||
@ -895,6 +902,8 @@ function TCocoaTabControl.exttabIndexOfTabViewItem(lTabPage: NSTabViewItem
|
|||||||
): NSInteger;
|
): NSInteger;
|
||||||
begin
|
begin
|
||||||
Result := fulltabs.indexOfObject(lTabPage);
|
Result := fulltabs.indexOfObject(lTabPage);
|
||||||
|
if Result = NSNotFound then
|
||||||
|
Result:= -1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaTabControlArrow }
|
{ TCocoaTabControlArrow }
|
||||||
|
@ -901,10 +901,11 @@ begin
|
|||||||
tb := TCocoaTabPageView(ATabControl.Page[AIndex].Handle);
|
tb := TCocoaTabPageView(ATabControl.Page[AIndex].Handle);
|
||||||
if not Assigned(tb) then Exit;
|
if not Assigned(tb) then Exit;
|
||||||
|
|
||||||
i := TCocoaTabControl(ATabControl.Handle).fulltabs.indexOfObject( tb.tabPage );
|
i := TCocoaTabControl(ATabControl.Handle).exttabIndexOfTabViewItem(tb.tabPage);
|
||||||
if (i = NSNotFound) then Exit;
|
if i < 0 then
|
||||||
|
Exit;
|
||||||
|
|
||||||
TCocoaTabControl(ATabControl.Handle).extselectTabViewItemAtIndex(NSInteger(i));
|
TCocoaTabControl(ATabControl.Handle).extselectTabViewItemAtIndex(i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TCocoaWSCustomTabControl.SetTabPosition(const ATabControl: TCustomTabControl; const ATabPosition: TTabPosition);
|
class procedure TCocoaWSCustomTabControl.SetTabPosition(const ATabControl: TCustomTabControl; const ATabPosition: TTabPosition);
|
||||||
|
Loading…
Reference in New Issue
Block a user