mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 15:25:07 +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;
|
cbnew : ICommonCallback;
|
||||||
begin
|
begin
|
||||||
idx := CocoaWidgetSet.RetainToCollect;
|
idx := CocoaWidgetSet.RetainToCollect;
|
||||||
win := self.keyWindow;
|
win := theEvent.window;
|
||||||
if Assigned(win)
|
if not Assigned(win) then win := self.keyWindow;
|
||||||
then cb := win.firstResponder.lclGetCallback
|
|
||||||
else cb := nil;
|
if Assigned(win) then
|
||||||
|
cb := win.firstResponder.lclGetCallback
|
||||||
|
else
|
||||||
|
cb := nil;
|
||||||
try
|
try
|
||||||
if (theEvent.type_ = NSKeyDown) or (theEvent.type_ = NSKeyUp) or
|
if (theEvent.type_ = NSKeyDown) or (theEvent.type_ = NSKeyUp) or
|
||||||
(theEvent.type_ = NSFlagsChanged) then begin
|
(theEvent.type_ = NSFlagsChanged) then begin
|
||||||
|
@ -2390,6 +2390,12 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
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;
|
function TCocoaWidgetSet.SetFocus(Handle: HWND): HWND;
|
||||||
var
|
var
|
||||||
Obj: NSObject;
|
Obj: NSObject;
|
||||||
@ -2418,7 +2424,7 @@ begin
|
|||||||
if lView.window.makeFirstResponder(lView.lclContentView) then
|
if lView.window.makeFirstResponder(lView.lclContentView) then
|
||||||
begin
|
begin
|
||||||
// initial focus set (right before the event loop starts)
|
// initial focus set (right before the event loop starts)
|
||||||
if not Assigned(NSApp.currentEvent) then
|
if NeedsFocusNotifcation(NSApp.currentEvent, lView.window) then
|
||||||
begin
|
begin
|
||||||
cb := lView.lclGetCallback;
|
cb := lView.lclGetCallback;
|
||||||
if Assigned(cb) then cb.BecomeFirstResponder;
|
if Assigned(cb) then cb.BecomeFirstResponder;
|
||||||
|
Loading…
Reference in New Issue
Block a user