From cda71b030dd0ac9d8b5b7fd8317462fe86ff3ee1 Mon Sep 17 00:00:00 2001 From: dmitry Date: Fri, 14 Jun 2019 19:18:30 +0000 Subject: [PATCH] cocoa: updating tabcontrol change notifications git-svn-id: trunk@61393 - --- lcl/interfaces/cocoa/cocoatabcontrols.pas | 24 ++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoatabcontrols.pas b/lcl/interfaces/cocoa/cocoatabcontrols.pas index febe449562..604c4b6e4a 100644 --- a/lcl/interfaces/cocoa/cocoatabcontrols.pas +++ b/lcl/interfaces/cocoa/cocoatabcontrols.pas @@ -471,13 +471,6 @@ begin if Assigned(callback) then begin callback.willSelectTabViewItem( IndexOfTab( self, tabViewItem) ); - - // This must be called, prior to notification about focus (firstResponder) change - // Focus changing goes as following: - // First page becomes visible - // Then focus is switching to the control of the page - // In Cocoa world, first "willSelect" runs, then "firstResponder" changes, then "didSelect" is fired - callback.didSelectTabViewItem( IndexOfTab( self, tabViewItem) ); end; end; @@ -486,10 +479,19 @@ procedure TCocoaTabControl.tabView_didSelectTabViewItem(tabView: NSTabView; begin //it's called together with "willSelect" - //if Assigned(callback) then - //begin - //callback.didSelectTabViewItem( IndexOfTab( self, tabViewItem) ); - //end; + if Assigned(callback) then + begin + // Expected LCL Focus changing goes as following: + // First page becomes visible + // Then focus is switching to the control of the page + // In Cocoa world, first "willSelect" runs, + // then "firstResponder" changes to Window + // then the views are reorded and the new View becomes a part + // of views chain (and attaches to the window + // the view is made "firstResponder" + // and finally "didSelect" is fired + callback.didSelectTabViewItem( IndexOfTab( self, tabViewItem) ); + end; // The recent clean up, drove the workaround below unnecessary // (at least the problem is not observed)