cocoa: initial (out of event loop) focus setting

git-svn-id: trunk@61398 -
This commit is contained in:
dmitry 2019-06-15 18:52:15 +00:00
parent 6f8ac4d6a1
commit 2d8ade5a97

View File

@ -2394,6 +2394,7 @@ function TCocoaWidgetSet.SetFocus(Handle: HWND): HWND;
var
Obj: NSObject;
lView: NSView;
cb: ICommonCallback;
begin
if Handle <> 0 then
begin
@ -2414,7 +2415,15 @@ begin
if lView.window <> nil then
begin
lView.window.makeKeyWindow;
lView.window.makeFirstResponder(lView.lclContentView);
if lView.window.makeFirstResponder(lView.lclContentView) then
begin
// initial focus set (right before the event loop starts)
if not Assigned(NSApp.currentEvent) then
begin
cb := lView.lclGetCallback;
if Assigned(cb) then cb.BecomeFirstResponder;
end;
end;
end else
Result := 0; // the view is on window, cannot set focus. Fail
end else