Cocoa/TabControl: add triggeringByLCL to distinguish whether the operation is triggered by User or Program

This commit is contained in:
rich2014 2023-10-12 01:02:20 +08:00
parent 82d467b50c
commit cbb27a8f6d

View File

@ -58,6 +58,8 @@ type
nextarr : NSButton;
public
triggeringByLCL: Boolean;
{ various indexes in fulltabs }
currentIndex : Integer; // index of the current tab
visibleLeftIndex: Integer; // index shown in TabView on the left
@ -633,6 +635,9 @@ procedure TCocoaTabControl.tabView_didSelectTabViewItem(tabView: NSTabView;
begin
//it's called together with "willSelect"
if triggeringByLCL then
exit;
currentIndex:= IndexOfTab( self, tabViewItem );
leftKeepAmount:= currentIndex - visibleLeftIndex;
@ -858,6 +863,8 @@ var
nextTabPage: NSTabViewItem;
prevTabPage: NSTabViewItem;
begin
triggeringByLCL:= true;
try
removedIndex := exttabIndexOfTabViewItem( removedTabPage );
isRemovingCurrentPage:= (removedIndex=currentIndex);
@ -913,6 +920,9 @@ begin
end;
UpdateTabAndArrowVisibility( self );
finally
triggeringByLCL:= false;
end;
end;
function TCocoaTabControl.exttabIndexOfTabViewItem(lTabPage: NSTabViewItem