1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

NSViewComponentPeer: Fix coordinate system conversion in contains()

The argument to hitTest must be in the superview's coordinate system.
The old implementation would sometimes break in the presence of nested
NSViews.
This commit is contained in:
reuk 2024-10-29 20:53:52 +00:00
parent f521a6cac1
commit fcf62ab105
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -540,12 +540,20 @@ public:
if (! isWindowAtPoint (viewWindow, screenPoint))
return false;
}
}
NSView* v = [view hitTest: NSMakePoint (viewFrame.origin.x + localPos.getX(),
viewFrame.origin.y + localPos.getY())];
const auto pointInSuperview = std::invoke ([&]
{
const auto local = NSMakePoint (localPos.x, localPos.y);
if (auto* superview = [view superview])
return [view convertPoint: local toView: superview];
return local;
});
NSView* v = [view hitTest: pointInSuperview];
return trueIfInAChildWindow ? (v != nil)
: (v == view);