Skip to content

Commit 252e8c1

Browse files
committed
When handling mouseMove on MacOS, check that the current peer is the topmost NSView before forwarding the events. Without this, a Component created via addDocumentWindow() with the nativeWindowToAttachTo argument set (i.e., creating a sub-NSView) would receive incorrect mouseExit events, as both it *and* its parent component would handle these mouseMove events, rapidly sending enter/exit messages back and forth between the two windows while the mouse moved.
1 parent 83dc660 commit 252e8c1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,12 +745,15 @@ void redirectMouseMove (NSEvent* ev)
745745
NSPoint windowPos = [ev locationInWindow];
746746
NSPoint screenPos = [[ev window] convertRectToScreen: NSMakeRect (windowPos.x, windowPos.y, 1.0f, 1.0f)].origin;
747747

748-
if (isWindowAtPoint ([ev window], screenPos))
749-
sendMouseEvent (ev);
750-
else
748+
if (isWindowAtPoint ([ev window], screenPos)) {
749+
if ([[[ev window] contentView] hitTest: windowPos] == view) {
750+
sendMouseEvent (ev);
751+
}
752+
} else {
751753
// moved into another window which overlaps this one, so trigger an exit
752754
handleMouseEvent (MouseInputSource::InputSourceType::mouse, MouseInputSource::offscreenMousePos, ModifierKeys::currentModifiers,
753755
getMousePressure (ev), MouseInputSource::defaultOrientation, getMouseTime (ev));
756+
}
754757

755758
showArrowCursorIfNeeded();
756759
}

0 commit comments

Comments
 (0)