Cocoa: fix #40581, TWinControl.Focused() when Killing Focus Control on macOS

This commit is contained in:
rich2014 2024-01-19 22:01:44 +08:00
parent d5967d39d5
commit 5f743c0387
3 changed files with 10 additions and 1 deletions

View File

@ -171,6 +171,8 @@ type
procedure DoSetMainMenu(AMenu: NSMenu; ALCLMenu: TMenu);
public
KeyWindow: NSWindow;
KillingFocus: Boolean;
// modal session
Modals : TList;
ModalCounter: Integer; // the cheapest way to determine if modal window was called

View File

@ -2148,6 +2148,8 @@ var
lclobj : TObject;
begin
Result := 0;
if KillingFocus then
Exit;
win := NSApp.keyWindow;
if not Assigned(win) then

View File

@ -1376,7 +1376,12 @@ end;
procedure TLCLCommonCallback.ResignFirstResponder;
begin
if not Assigned(Target) then Exit;
LCLSendKillFocusMsg(Target);
CocoaWidgetSet.KillingFocus:= true;
try
LCLSendKillFocusMsg(Target);
finally
CocoaWidgetSet.KillingFocus:= false;
end;
end;
procedure TLCLCommonCallback.DidBecomeKeyNotification;