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