mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-08 01:17:29 +01:00
Cocoa: Rework window lookup and mousemove event activation
git-svn-id: trunk@44120 -
This commit is contained in:
parent
d938c3b9e5
commit
c789f1367f
@ -374,6 +374,7 @@ type
|
||||
procedure didBecomeKeyNotification(sender: NSNotification); message 'didBecomeKeyNotification:';
|
||||
procedure didResignKeyNotification(sender: NSNotification); message 'didResignKeyNotification:';
|
||||
|
||||
|
||||
public
|
||||
isembedded: Boolean; // true - if the content is inside of another control, false - if the content is in its own window;
|
||||
ownwin: NSWindow;
|
||||
@ -605,6 +606,8 @@ end;
|
||||
|
||||
procedure TCocoaWindowContent.viewWillMoveToWindow(newWindow: NSWindow);
|
||||
begin
|
||||
if newWindow<>nil then
|
||||
newWindow.setAcceptsMouseMovedEvents(True);
|
||||
if not isembedded and (newWindow <> window) then
|
||||
begin
|
||||
window.close;
|
||||
|
||||
@ -1042,26 +1042,28 @@ var
|
||||
winrect: TRect;
|
||||
windows: NSArray;
|
||||
win: integer;
|
||||
window: NSWindow;
|
||||
|
||||
window, windowbelowpoint: NSWindow;
|
||||
p:NSPoint;
|
||||
winnr:NSInteger;
|
||||
begin
|
||||
Result := 0;
|
||||
if not assigned(NSApp) then
|
||||
Exit;
|
||||
|
||||
|
||||
windows := NSApp.windows;
|
||||
for win := 0 to windows.count - 1 do
|
||||
begin
|
||||
window:=windows.objectAtIndex(win);
|
||||
if window.isKeyWindow then
|
||||
p.x:=Point.X;
|
||||
p.y:=window.screen.frame.size.height-Point.Y;
|
||||
winnr:=NSWindow.windowNumberAtPoint_belowWindowWithWindowNumber(p,0);
|
||||
windowbelowpoint:=NSApp.windowWithWindowNumber(winnr);
|
||||
if windowbelowpoint=window then
|
||||
begin
|
||||
winrect := window.lclFrame;
|
||||
if PtInRect(winrect, Point) then
|
||||
begin
|
||||
Result:=RecurseSubviews(window.contentView, Point);
|
||||
if Result<>0 then
|
||||
exit;
|
||||
end;
|
||||
Result:=RecurseSubviews(window.contentView, Point);
|
||||
if Result<>0 then
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -435,7 +435,8 @@ var
|
||||
if AParams.WndParent <> 0 then
|
||||
begin
|
||||
NSView(APArams.WndParent).addSubView(cnt);
|
||||
cnt.window.setAcceptsMouseMovedEvents(True);
|
||||
if cnt.window<>nil then
|
||||
cnt.window.setAcceptsMouseMovedEvents(True);
|
||||
cnt.callback.IsOpaque:=true;
|
||||
// todo: We have to find a way to remove the following notifications save before cnt will be released
|
||||
// NSNotificationCenter.defaultCenter.addObserver_selector_name_object(cnt, objcselector('didBecomeKeyNotification:'), NSWindowDidBecomeKeyNotification, cnt.window);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user