JUCE icon indicating copy to clipboard operation
JUCE copied to clipboard

[Bug]: A NSViewComponent child of DocumentWindow does not receive the mouseMove event anymore.

Open esseci77 opened this issue 11 months ago • 1 comments

Detailed steps on how to reproduce the bug

Create a DocumentWindow with its main Component. Create a NSViewComponent derived class with mouseMove event overridden, and add this class to the main Component. When you pass the pointer over the NSViewComponent derived object area, the mouseMove callback is never called (but, i.e. the mouseClick works). This happens from 8.0.4. I had to downgrade my app to 8.0.3 to restore the functionality of my window.

After some digging, it seems that the culprit is in the redirectMouseMove() method contained in juce_NSViewComponentPeer_mac.mm:

(...)
if (isWindowAtPoint ([ev window], screenPos))
        {
            if (contains (getMousePos (ev, view).roundToInt(), false))
                sendMouseEvent (ev);
        }
(...)

the sendMouseEvent() is never called. Looking into contains() if found this code:

(...)
NSView* v = [view hitTest: pointInSuperview];

 return trueIfInAChildWindow ? (v != nil)
                                    : (v == view);

the [view hitTest] returned a pointer to the NSView hosted by my NSViewComponent derived class, but since trueIfInAChildWindow is set to false (last argument of contains()), and since v is not the view of the calling peer, the method returns false.

What is the expected behaviour?

When I move the mouse pointer over a NSViewComponent, the overridden mouseMove() should be called like in any other Component.

Operating systems

macOS

What versions of the operating systems?

Sequoia 15.1.1

Architectures

Arm64/aarch64

Stacktrace

No response

Plug-in formats (if applicable)

No response

Plug-in host applications (DAWs) (if applicable)

No response

Testing on the develop branch

I have not tested against the develop branch

Code of Conduct

  • [X] I agree to follow the Code of Conduct

esseci77 avatar Dec 12 '24 11:12 esseci77

I have a similar issue in 8.0.6 I need to have an area of my application renderable by my metal based graphics engine. To achieve this i have a custom NSView that sets up a CAMetalLayer. I'm adding my view as subview to the view backing the top level component by calling NSView::addSubview. This works as expected in 8.0.3, but not in 8.0.6. Setting up the view's nextResponder (which is not needed in 8.0.3, but might be a path to a solution now) does make the movement events end up in juce, but my MouseListener doesn't get the mouse movement events so it seems to think the mouse is outside of the juce window anyway.

MennoVink avatar Jun 07 '25 17:06 MennoVink