# \[BUG\] 6.1.6 changes mouse events behavior?

**URL:** <https://forum.juce.com/t/bug-6-1-6-changes-mouse-events-behavior/50604>\
**Category:** General JUCE discussion\
**Created:** [March 15, 2022, 6:34pm UTC](https://forum.juce.com/t/bug-6-1-6-changes-mouse-events-behavior/50604 "2022-03-15T18:34:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mqtthiqs](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mqtthiqs/32/14729_2.png) [@mqtthiqs](https://forum.juce.com/u/mqtthiqs)\
**Post date:** [March 15, 2022, 6:34pm UTC](https://forum.juce.com/t/bug-6-1-6-changes-mouse-events-behavior/50604/1 "2022-03-15T18:34:42Z")

</div>

AFAICT [this commit](https://github.com/juce-framework/JUCE/commit/101a886821aec37d9339d60b34b53057d28302a9) changes the behavior of mouse events in a way that the commit doesn’t document. At least on macOS Monterey, with a regular (although _Magic_ 🪄) mouse.

**Before:** a mouse down event triggered both `mouseDown` and `mouseDrag`, before any mouse movement.  
**After:** a mouse down event triggers only `mouseDown`; `mouseDrag` is called upon actual movement while the button is held.

This seems to me like quite a big, observable change that might need more documentation if that’s what was intended. But here is at least one place in JUCE where it entails a regression:

I have a `LassoComponent` with associated `SelectedItemSet`, and I use it as per the documentation:

- in my `mouseDown` I call `lasso.beginLasso()`
- in my `mouseDrag` I call `lasso.dragLasso()`
- in my `mouseUp` I call `lasso.endLasso()`

Before the patch, a single click would clear my selection (as expected I guess, since all lasso selection systems behave like this); after the patch I need to drag the mouse cursor 1px to clear the selection.

Could maybe @attila comment on this?

---

<div class="post-metadata">

**Author:** ![juan1979](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@juan1979](https://forum.juce.com/u/juan1979)\
**Post date:** [March 15, 2022, 6:42pm UTC](https://forum.juce.com/t/bug-6-1-6-changes-mouse-events-behavior/50604/2 "2022-03-15T18:42:57Z")

</div>

I’m still using Juce 6.1.0 (I have it a bit hacked so I only update when it’s justified), and the mouse always worked as you described in you **After** behavior. It doesn’t send a mouseDrag until you actually drag the mouse, which seems the right thing for me.

Maybe was it an OSX bug recently fixed?

---

<div class="post-metadata">

**Author:** ![mqtthiqs](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mqtthiqs/32/14729_2.png) [@mqtthiqs](https://forum.juce.com/u/mqtthiqs)\
**Post date:** [March 15, 2022, 7:12pm UTC](https://forum.juce.com/t/bug-6-1-6-changes-mouse-events-behavior/50604/3 "2022-03-15T19:12:13Z")

</div>

The behavior change is directly linked to JUCE’s change, not to an OS update: I’ve bisected it down to the commit linked above.

Interesting that you get the **after** behavior; I’ve been using Juce “only” for a year, but in the several JUCE/macOS combination I’ve tried I think I always saw the **before** one. I agree with you that **after** feels more right; I don’t know which is the “official” one from JUCE.

---

<div class="post-metadata">

**Author:** ![juan1979](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@juan1979](https://forum.juce.com/u/juan1979)\
**Post date:** [March 15, 2022, 7:19pm UTC](https://forum.juce.com/t/bug-6-1-6-changes-mouse-events-behavior/50604/4 "2022-03-15T19:19:03Z")

</div>

I’m sorry, I forgot to state I’m using Windows! But it should be consistent between platforms anyway

---

<div class="post-metadata">

**Author:** ![juan1979](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@juan1979](https://forum.juce.com/u/juan1979)\
**Post date:** [March 15, 2022, 7:23pm UTC](https://forum.juce.com/t/bug-6-1-6-changes-mouse-events-behavior/50604/5 "2022-03-15T19:23:46Z")

</div>

Also, for your problem, I suggest you use in your `mouseDown`, if **After** behavior is the right one, both calls, the `lasso.beginLasso()` and `lasso.dragLasso()`. In the `mouseDrag()`, the `lasso.dragLasso()` as usual. I never used that component so I’m not sure, but it should work.

---

<div class="post-metadata">

**Author:** ![mqtthiqs](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mqtthiqs/32/14729_2.png) [@mqtthiqs](https://forum.juce.com/u/mqtthiqs)\
**Post date:** [March 15, 2022, 9:11pm UTC](https://forum.juce.com/t/bug-6-1-6-changes-mouse-events-behavior/50604/6 "2022-03-15T21:11:16Z")

</div>

Yes, that’s how I fixed the problem right away. I’m just mentioning it here for JUCE’s devs because `LassoComponent` (and probably others) is not synced with its doc anymore; they might want to know that a recent commit introduced this regression.

---

<div class="post-metadata">

**Author:** ![attila](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/attila/32/11206_2.png) [@attila](https://forum.juce.com/u/attila)\
**Post date:** [March 16, 2022, 8:56am UTC](https://forum.juce.com/t/bug-6-1-6-changes-mouse-events-behavior/50604/7 "2022-03-16T08:56:40Z")

</div>

Thanks for bringing this to our attention! I’ll take a closer look at LassoComponent and see if the documentation could be improved.

Before the change we had a bug report that the behaviour in Monterey, which you described in **Before** , is breaking existing code. On Windows and even on MacOS up until Monterey, the regular behaviour was what you described in **After** and the change was aiming to restore this.

---

<div class="post-metadata">

**Author:** ![yfede](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yfede/32/506_2.png) [@yfede](https://forum.juce.com/u/yfede)\
**Post date:** [March 16, 2022, 9:14am UTC](https://forum.juce.com/t/bug-6-1-6-changes-mouse-events-behavior/50604/8 "2022-03-16T09:14:33Z")

</div>

For reference, the (spurious) call to mouseDrag() immediately after mouseDown() (i.e. the **Before** behaviour) affected the macOS implementation since 2016.

At the time, the introduction of that behavior felt like a bug to many (me included): while it’s true that a mouseDrag() event after a mouseDown() must be supported by the application, still the fact that a mouseDrag() could be triggered even in the case of absolutely no movement (for example, clicking while the mouse is lifted from the desk) seemed a little counterintuitive.

In addition to that, AFAIK the Windows implementation always behaved in the **After** fashion, meaning that a sublte inconsistency existed between the two platforms since then.

If the macOS implementation is finally being reconciled with the Windows implementation, hooray!  
I hope the users that wrote in those in topics to report the issue, are still around to see it finally fixed 🙌

See:

> [@MouseDrag called on MouseDown](https://forum.juce.com/t/mousedrag-called-on-mousedown/18353):
>
> Hi, I’ve just updated from JUCE v3.2.0 to v4.2.3 It seems like there’s a behaviour change where Component::mouseDrag is now being called on mouse down. Currently I’ve only tested this on OSX 10.11.5. Looking through the call stack it seems that the mouseDown callback in juce\_mac\_NSViewComponentPeer.mm internally results in a mouseDrag event being triggered. Is this an intentional change? I’ve never considered that a drag event could be called on mouse down event before and only noticed beca…

> [@On mac osx mouseDrag gets called on mouseDown](https://forum.juce.com/t/on-mac-osx-mousedrag-gets-called-on-mousedown/17418):
>
> For any component any time a mouseDown happens, mouseDrag gets called even if I dont move the mouse? The event position is the same in both mouseDown and mouseDrag. This does not seem to happen on windows. Only on mac os. I am on 10.10.5

---

<div class="post-metadata">

**Author:** ![attila](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/attila/32/11206_2.png) [@attila](https://forum.juce.com/u/attila)\
**Post date:** [March 16, 2022, 9:44am UTC](https://forum.juce.com/t/bug-6-1-6-changes-mouse-events-behavior/50604/9 "2022-03-16T09:44:35Z")

</div>

Thanks for clarifying.

It seems there has been a subtle inconsistency for a long time. What I believe Monterey changed is it started reporting changing pressure for non pressure sensitive devices.

So if you’ve been using a trackpad or magic mouse you were subject to this inconsistency even before Monterey, and if you used a generic mouse you came across it only then.

---

<div class="post-metadata">

**Author:** ![mqtthiqs](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mqtthiqs/32/14729_2.png) [@mqtthiqs](https://forum.juce.com/u/mqtthiqs)\
**Post date:** [March 16, 2022, 7:13pm UTC](https://forum.juce.com/t/bug-6-1-6-changes-mouse-events-behavior/50604/10 "2022-03-16T19:13:48Z")

</div>

Thanks @attila and @yfede for the explanations, it makes a bit more sense now.
