# \[Bug report\] MouseWasDraggedSinceMouseDown

**URL:** <https://forum.juce.com/t/bug-report-mousewasdraggedsincemousedown/27153>\
**Category:** General JUCE discussion\
**Created:** [April 9, 2018, 10:47pm UTC](https://forum.juce.com/t/bug-report-mousewasdraggedsincemousedown/27153 "2018-04-09T22:47:52Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![zonrobin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zonrobin/32/1961_2.png) [@zonrobin](https://forum.juce.com/u/zonrobin)\
**Post date:** [April 9, 2018, 10:47pm UTC](https://forum.juce.com/t/bug-report-mousewasdraggedsincemousedown/27153/1 "2018-04-09T22:47:52Z")

</div>

Hi,

when I click and hold mouse for a half second (approx.) or more, the MouseEvent i get at mouseUp callback has wasMovedSinceMouseDown flag set to true even though I’m pretty sure I didn’t moved the mouse (tested many times with mouse off the table). Everything is ok if the mouse click is shorter.

Maybe it’s caused by MouseInputSourceInternal::isDragging() which returns true if isAnyMouseButtonDown() ?

> <https://github.com/WeAreROLI/JUCE/blob/master/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp#L40>

Win 7x64.

---

<div class="post-metadata">

**Author:** ![oxxyyd](https://avatars.discourse-cdn.com/v4/letter/o/e47c2d/32.png) [@oxxyyd](https://forum.juce.com/u/oxxyyd)\
**Post date:** [April 10, 2018, 1:57am UTC](https://forum.juce.com/t/bug-report-mousewasdraggedsincemousedown/27153/2 "2018-04-10T01:57:13Z")

</div>

I noticed this too a year ago. Began to use getDistanceFromDragStart() instead to check for mouse movements.

---

<div class="post-metadata">

**Author:** ![zonrobin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zonrobin/32/1961_2.png) [@zonrobin](https://forum.juce.com/u/zonrobin)\
**Post date:** [April 10, 2018, 7:26am UTC](https://forum.juce.com/t/bug-report-mousewasdraggedsincemousedown/27153/3 "2018-04-10T07:26:23Z")

</div>

Unfortunately getDistanceFromDragStart() returns a diff of dragStart and dragEnd postitions which doesn’t cover the case where user drags but returns to dragStart position (eg. when using dragscroll).

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [April 10, 2018, 9:55am UTC](https://forum.juce.com/t/bug-report-mousewasdraggedsincemousedown/27153/4 "2018-04-10T09:55:29Z")

</div>

`mouseWasDraggedSinceMouseDown()` indicates that the user is attempting a drag gesture and the event isn’t just a simple click, so it will return true if the mouse has moved significantly **or** if it has been held down for a significant period of time.

If you are just interested in whether the mouse has been moved since mouse down then you can use the `MouseInputSource::hasMovedSignificantlySincePressed()` method, accessing it through the `source` member of the `MouseEvent`.

---

<div class="post-metadata">

**Author:** ![lalala](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/lalala/32/8577_2.png) [@lalala](https://forum.juce.com/u/lalala)\
**Post date:** [April 10, 2018, 10:05am UTC](https://forum.juce.com/t/bug-report-mousewasdraggedsincemousedown/27153/5 "2018-04-10T10:05:51Z")

</div>

> [@ed95](#):
>
> or if it has been held down for a significant period of time.

the doc should be amended then. atm it says : `It will return true if the user has dragged the mouse more than a few pixels from the place where the mouse-down occurred.`

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [April 10, 2018, 10:10am UTC](https://forum.juce.com/t/bug-report-mousewasdraggedsincemousedown/27153/6 "2018-04-10T10:10:37Z")

</div>

Yep, I’ll update that.

---

<div class="post-metadata">

**Author:** ![zonrobin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zonrobin/32/1961_2.png) [@zonrobin](https://forum.juce.com/u/zonrobin)\
**Post date:** [April 10, 2018, 10:17am UTC](https://forum.juce.com/t/bug-report-mousewasdraggedsincemousedown/27153/7 "2018-04-10T10:17:48Z")

</div>

Whould be nice to have switch

`mouseWasDraggedSinceMouseDown(bool includeDragAttempt = true)`

so others would know about that 🙂

EDIT: Just tested that and it seems it’s not like you say:

```
    bool hasMouseMovedSignificantlySincePressed() const noexcept
{
    return mouseMovedSignificantlySincePressed
            || lastTime > mouseDowns[0].time + RelativeTime::milliseconds (300);
}

```

That method returns true on long mouseDown.

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [April 10, 2018, 10:22am UTC](https://forum.juce.com/t/bug-report-mousewasdraggedsincemousedown/27153/8 "2018-04-10T10:22:56Z")

</div>

You’ll need to pull the latest develop, I updated it this morning [here](https://github.com/WeAreROLI/JUCE/commit/7cf8e28fdd7ff18b69dbcdb37e58a013cc27758f).

---

<div class="post-metadata">

**Author:** ![zonrobin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zonrobin/32/1961_2.png) [@zonrobin](https://forum.juce.com/u/zonrobin)\
**Post date:** [April 10, 2018, 10:23am UTC](https://forum.juce.com/t/bug-report-mousewasdraggedsincemousedown/27153/9 "2018-04-10T10:23:43Z")

</div>

Cool, thanks!
