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:
parent
f521a6cac1
commit
fcf62ab105
1 changed files with 11 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue