cocoa: update focus notification to run during SetFocus, if current event is processed for another window

git-svn-id: trunk@61401 -
This commit is contained in:
dmitry 2019-06-16 13:23:22 +00:00
parent bc2d633fdc
commit 3123d5b440
2 changed files with 14 additions and 5 deletions

View File

@ -484,10 +484,13 @@ var
cbnew : ICommonCallback;
begin
idx := CocoaWidgetSet.RetainToCollect;
win := self.keyWindow;
if Assigned(win)
then cb := win.firstResponder.lclGetCallback
else cb := nil;
win := theEvent.window;
if not Assigned(win) then win := self.keyWindow;
if Assigned(win) then
cb := win.firstResponder.lclGetCallback
else
cb := nil;
try
if (theEvent.type_ = NSKeyDown) or (theEvent.type_ = NSKeyUp) or
(theEvent.type_ = NSFlagsChanged) then begin

View File

@ -2390,6 +2390,12 @@ begin
Result := True;
end;
function NeedsFocusNotifcation(event: NSEvent; win: NSWindow): Boolean;
begin
Result := (Assigned(win))
and (not Assigned(event) or (event.window <> win));
end;
function TCocoaWidgetSet.SetFocus(Handle: HWND): HWND;
var
Obj: NSObject;
@ -2418,7 +2424,7 @@ begin
if lView.window.makeFirstResponder(lView.lclContentView) then
begin
// initial focus set (right before the event loop starts)
if not Assigned(NSApp.currentEvent) then
if NeedsFocusNotifcation(NSApp.currentEvent, lView.window) then
begin
cb := lView.lclGetCallback;
if Assigned(cb) then cb.BecomeFirstResponder;