Component::mouseMove unexpectedly called after Component::mouseUp event

In my Component, after releasing a mouse click, mouseUp function is correctly called. But then it’s strangly followed by an mouseMove event. It looks like JuceNSViewClass::mouseUp “redirects” the call to mouseMove function. Why is there the call of JuceNSViewClass::mouseUp afther my own mouseUp event is fully completed? How can I avoid the mouseMove event being called after my mouseUp event?

A screenshot of the call stack:
Screenshot 2022-03-18 at 19.05.30

thanks!

Can you please give some more details about what you are doing? When you release the mouse button usually the pointer is over the component, yet. So if you move the mouse now a mouseMove is called.

Are you confusing mouseMove and mouseDrag?

mouseDrag will indeed only be called when moving the mouse between mouseDown and mouseUp.

mouseMove will be called when hovering the mouse over the component.

So what you are observing seems reasonable to me: you release the mouse button, get a mouseUp event and immediately a mouseMove because you effectively end up in the “hovering” state.

I merely press the mouse key and release the key without moving the mouse. I just tested it in the example project from JUCE (componentDemo) and am observing the same behavior - after releasing the mouse (so after the mouseUp is called), the juce::JuceNSViewClass::mouseUp is called, which will end up calling the mouseMove function in my Component (please see the attached screen shot for the full call stack). As it’s reproducible in the example project, I guess it is an expected behavior but I still don’t see why Juce is doing this.

Hello

Perhaps you can filter the mouseMove event : if there is no movement between the last mouseUp event, you simply ignore the mouseMove event. You cannot avoid the fact that the user can move the mouse a bit after a mouse click.
You just have to store somewhere the position of the last mouseUp event.