[Bug]: MacOS addToDesktop w/ nativeWindowToAttachTo handles mouseMove incorrectly

Detailed steps on how to reproduce the bug:
This sample code reproduces the problem. On MacOS, create a button as a child NSView of the current component’s window, make sure it’s visible etc, and then mouse over it. What you’ll see is that it may temporarily flash to the highlighted isOver state, it will immediately revert to not being highlighted, as if the mouse exited it (even though it didn’t).

 juce::TextButton button{"Mouse over me"};

 button.setOpaque(true);
 button.setVisible(true);
 button.addToDesktop(0, getWindowHandle());
 button.toFront(false);
 button.setBounds(100, 100, 50, 50);

I sent out a PR to fix this:

But I have gotten no traction on either the bug report or the PR, so I’m posting here to the forums as that’s what contributing.md suggests I’m supposed to do.

'Twould be lovely if someone working on JUCE could take a look at this. not sure how I could be a better open-source citizen than to report a bug with a repro case and a PR to fix it…

1 Like

Thanks for your patience. We’ve now added a fix for this issue on the develop branch.

The fix we merged is fairly similar to the one you suggested, but we call the NSViewComponentPeer::contains function rather than calling hitTest directly:

This also unearthed an issue where the argument to hitTest inside NSViewComponentPeer::contains was not correctly using the superview’s coordinate space. That issue is addressed here:

1 Like

Looks great; very glad to hear you found and fixed some other issues here as well. Thank you!