Download

UMG Drag & Drop precision issue; drag threshold.

Hi folks,

I need to move canvas panel slot widgets around on a canvas panel with drag and drop functionality.
I followed the youtube drag and drop tutorial with the function overrides found here:
https://www.youtube.com/watch?v=wyC5vl64V9k&t=1s

I’m encountering an issue with the final “drop” after dragging the widget to its new location. Specifically the widget always “rubberbands” a little bit off to the side once I release the mouse button to complete the drop.

Today I recognized that the likely culprit is that the drag and drop operation doesn’t fire at the exact moment that I begin to move the mouse, but instead makes use of a “drag threshold” value.
The result is that the screen space “offset” vector2d that I save is itself always a little off by that threshold increment.

Has anyone else encountered this issue?
Does anyone know if/how you can reduce the drag threshold in blueprints?

Thanks!

The drag and drop system has an inherent drag threshold - the one you’ve found. This is by design. If you need things to begin moving immediately, rather than asking Slate to detect a drag, you can simply update the Reply to BeginDragDrop, rather than asking it to DetectDrag.

Direct calls to BeginDragDrop isn’t actually exposed to Blueprints, but SObjectWidget::OnDragDetected, contains an example of what you’d need to create a utility function to do.

Alternatively you could forgo the drag drop, and simply move the location when the mouse is moved, and you capture it on down, for example.

I’ve found that I can eliminate the rubberbanding effect on drop simply by setting my offset in the onDragDetected override as opposed to onMouseButtonDown as was done in the video.
The mouse position slippage is still there but takes place as soon as the drag starts so it’s not really noticeable. At the present stage that’s good enough for me.

In any case, thanks for the suggestions, I’ll come back to it when I need to polish my UI performance.

Is there a way to adjust this threshold? It’s a bit too sensitive when using VR motion controllers or an HMD gaze cursor. I’m willing to change the source code if needed. Thanks!