Worth noting that this does not work if you add a Button to the Widget (in this example, MyWindow). If your UserWidget-inherited Widget has a Button, that Button will stop the DragDropOp from working. In that case, you need to jump through a few more hoops.
If MyWindow is going to have a Button, it needs an extra function in MyWindow.h:
UFUNCTION(BlueprintCallable)
FEventReply RedirectMouseDownToWidget(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent);
And its definition in MyWindow.cpp:
FEventReply MyWindow::RedirectMouseDownToWidget(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent)
{
FEventReply reply;
reply.NativeReply = NativeOnMouseButtonDown(InGeometry, InMouseEvent);
return reply;
}
.
This is a sort of redirect hack to get the DragDropOp to function even if the Button is dragged. The implementation of the MyWindow-derived Blueprint then needs to override its OnPreviewMouseButtonDown
function to use the new redirect function:
.
Once these extra steps are done, the DragDropOp successfully works in conjunction with a Button.