juce::MouseInputSourceInternal::handleEvent() - Different Behaviour on Mac & Windows

Hi all,

I’ve been debugging an odd mouse issue that only happens on Mac. Turns out it’s due to a subtle inconsistency in juce::MouseInputSourceInternal::handleEvent() where it does one thing on Mac but another on Windows.

The issue is the following code at the top of handlEvent():

        const bool pressureChanged = (pressure != newPressure);
        pressure = newPressure;

On Windows 10, using a normal mouse, pressure is always 0.

However, on Mac Monterey using the same mouse, pressure is 0 on mouse down but 1 on mouse up for some reason. Consequently, pressureChanged is set to true, and the code goes on to set shouldUpdate to true as a result. shouldUpdate is then passed to setScreenPos() as the forceUpdate parameter.

In short, handleUpdate() winds up calling setScreenPos() with a forceUpdate parameter of false on Windows but true on Mac.

The result of all this is that setScreenPos() treats the mouse click as a mouse drag (even though the mouse position hasn’t moved)! On Mac, it ends up triggering a mouseDrag() call which doesn’t happen on Windows.

And in our case it manifests as a mouse handling bug in one of our components.

I’d expect the same behavior on both platforms. Please can this be investigated/fixed?

Many thanks!

Just bumping this because it seems like a legit JUCE bug. Thanks.


Thank you for reporting this.

There’s a change out on develop that should fix this

That’s great news! Thanks very much @attila :slight_smile: