cocoa: update tab selection for CocoaTabControl

git-svn-id: trunk@58445 -
This commit is contained in:
dmitry 2018-07-06 04:00:28 +00:00
parent 99bdd1e53a
commit 1780f9b870
2 changed files with 34 additions and 10 deletions

View File

@ -98,6 +98,8 @@ type
message 'extTabPrevButtonClick:';
procedure extTabNextButtonClick(sender: id);
message 'extTabNextButtonClick:';
procedure extselectTabViewItemAtIndex(index: NSInteger);
message 'extselectTabViewItemAtIndex:';
end;
{ TCocoaTabPageView }
@ -363,6 +365,28 @@ begin
UpdateTabAndArrowVisibility(self);
end;
procedure TCocoaTabControl.extselectTabViewItemAtIndex(index: NSInteger);
var
idx : integer;
itm : NSTabViewItem;
i : NSUInteger;
begin
if (index<0) or (index>=fulltabs.count) then Exit;
itm := NSTabViewItem(fulltabs.objectAtIndex(index));
i := tabViewItems.indexOfObject(itm);
if i <> NSNotFound then
begin
inherited selectTabViewItemAtIndex(NSInteger(i));
end
else begin
leftmost := index;
UpdateTabAndArrowVisibility(self);
i := tabViewItems.indexOfObject(itm);
inherited selectTabViewItemAtIndex(NSInteger(i));
end;
end;
function TCocoaTabControl.lclIsEnabled: Boolean;
begin
Result:=lclEnabled and ((Assigned(superview) and superview.lclIsEnabled) or not Assigned(superview));

View File

@ -584,22 +584,22 @@ class procedure TCocoaWSCustomTabControl.SetPageIndex(const ATabControl: TCustom
var
lTabControl: TCocoaTabControl;
lTabCount: NSInteger;
h : id;
i : NSUInteger;
tb : TCocoaTabPageView;
begin
{$IFDEF COCOA_DEBUG_TABCONTROL}
WriteLn('[TCocoaWSCustomTabControl.SetPageIndex]');
{$ENDIF}
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
lTabControl := TCocoaTabControl(ATabControl.Handle);
{$IFDEF COCOA_DEBUG_TABCONTROL}
WriteLn(Format('[TCocoaWSCustomTabControl.SetPageIndex] lTabControl=%d', [PtrUInt(lTabControl)]));
{$ENDIF}
lTabCount := lTabControl.numberOfTabViewItems();
{$IFDEF COCOA_DEBUG_TABCONTROL}
WriteLn(Format('[TCocoaWSCustomTabControl.SetPageIndex] lTabCount=%d', [lTabCount]));
{$ENDIF}
if (AIndex < 0) or (AIndex >= lTabCount) then Exit;
if (AIndex<0) or (AIndex>=ATabControl.PageCount) then Exit;
tb := TCocoaTabPageView(ATabControl.Page[AIndex].Handle);
if not Assigned(tb) then Exit;
lTabControl.selectTabViewItemAtIndex(AIndex);
i := TCocoaTabControl(ATabControl.Handle).fulltabs.indexOfObject( tb.tabPage );
if (i = NSNotFound) then Exit;
TCocoaTabControl(ATabControl.Handle).extselectTabViewItemAtIndex(NSInteger(i));
end;
class procedure TCocoaWSCustomTabControl.SetTabPosition(const ATabControl: TCustomTabControl; const ATabPosition: TTabPosition);