From ac6d122b39d9522514b20a28d58b5de1ab598f1e Mon Sep 17 00:00:00 2001 From: rich2014 Date: Sat, 17 Aug 2024 23:13:21 +0800 Subject: [PATCH] Cocoa: avoid unexpected changes in the focus control during TabControl update --- lcl/interfaces/cocoa/cocoatabcontrols.pas | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lcl/interfaces/cocoa/cocoatabcontrols.pas b/lcl/interfaces/cocoa/cocoatabcontrols.pas index 8df60b7953..3a03089d75 100644 --- a/lcl/interfaces/cocoa/cocoatabcontrols.pas +++ b/lcl/interfaces/cocoa/cocoatabcontrols.pas @@ -363,7 +363,12 @@ procedure UpdateTabAndArrowVisibility(aview: TCocoaTabControl); var showNext : Boolean; showPrev : Boolean; + responder: NSResponder; begin + responder:= nil; + if Assigned(aview.window) then + responder:= aview.window.firstResponder; + ReviseTabs(aview, showPrev, showNExt); aview.updateVariousIndex; if Assigned(aview.prevarr) then @@ -384,6 +389,11 @@ begin aview.nextarr.setHidden(not showNext); {$endif} end; + + if Assigned(aview.window) then begin + if Assigned(responder) and (responder<>aview.window.firstResponder) then + aview.window.makeFirstResponder(responder); + end; end; function IndexOfTab(ahost: TCocoaTabControl; atab: NSTabViewItem): Integer;