Cocoa: fix TCocoaWidgetSet.WindowFromPoint() by GetCocoaWindowAtPos()

This commit is contained in:
rich2014 2023-09-29 17:46:57 +08:00
parent 1f82cd542f
commit 48990d892e

View File

@ -1554,11 +1554,8 @@ end;
function TCocoaWidgetSet.WindowFromPoint(Point: TPoint): HWND;
var
windows: NSArray;
win: integer;
window, windowbelowpoint: NSWindow;
window:NSWindow;
p:NSPoint;
winnr:NSInteger;
begin
Result := 0;
if not assigned(NSApp) then
@ -1566,19 +1563,9 @@ begin
p.x:=Point.X;
p.y:=NSScreenZeroHeight-Point.Y;
winnr:=NSWindow.windowNumberAtPoint_belowWindowWithWindowNumber(p,0);
windowbelowpoint:=NSWindow(NSApp.windowWithWindowNumber(winnr));
windows := NSApp.windows;
for win := 0 to windows.count - 1 do
begin
window:=windows.objectAtIndex(win);
if windowbelowpoint=window then
begin
Result:= HWND(window.contentView);
exit;
end;
end;
window := GetCocoaWindowAtPos(p);
if Assigned(window) then
Result:= HWND(window.contentView);
end;