[Bug report] MouseWasDraggedSinceMouseDown


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() ?

Win 7x64.

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

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).

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.

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.

Yep, I’ll update that.


Whould be nice to have switch

mouseWasDraggedSinceMouseDown(bool includeDragAttempt = true)

so others would know about that :slight_smile:

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.

You’ll need to pull the latest develop, I updated it this morning here.

Cool, thanks!