mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 04:58:11 +02:00
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:
parent
bc2d633fdc
commit
3123d5b440
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user