Begin new drag after calling drop

Hey, everyone.

I’ve recently set up a basic grid-based inventory system using UMG widgets which allows for different-sized items (Essentially a jigsaw inventory).
Each item contains a drag-and-drop operation which starts/ends when the left mouse button is released, meaning they are picked up and dropped on separate clicks.
My inventory contains an override for the onDrop event, which assigns a grid slot based on the mouse position for the item to land in, checks for existing items that might block it, and places it into the grid.

Here’s an example of how it works right now:

My current issue is shown near the end of the clip; the function checks to see how many items are blocking the drop, because I want to start dragging the blocking item if there’s only one, or swap the dragged item for it.
I’ve managed to have the function find the number of items in the drop area, as well as return the single blocking item (if there’s only one), but I can’t seem to force the item in the grid to start dragging after dropping the previous item.

Is there a Blueprint method to force a new drag-and-drop operation to start during a drop call, given a reference to the widget I want to drag?

Thanks in advance!

Check this thread out:

@**Drealz **managed to figure out how to pull off precisely what you’re trying to do

Hey Everynone.

I’ve read through the thread you linked, and it *sounds *like the solution there was to use a different method besides the engine’s drag-and-drop, by making a new widget that follows the mouse manually and does another action when it’s destructed?

I’ve been trying to get a similar result by using a different widget which runs other events on construct/destruct as the D&D operation’s drag visual, which seems promising but still doesn’t have an obvious way to call another onDragDetected, or start another operation.
Is manually following the mouse the only way to do this in Blueprint?

Bump. After trying this for a while, there’s something I still don’t quite understand.
As far as I can tell, the Pointer Event from the onDrop event contains the same information as the Mouse Event from onMouseButtonUp, so I’ve tried calling Detect Drag if Pressed using it.

…But for some reason, this doesn’t fire onDragDetected? I’ve tried passing the Pointer Event to the item I’m trying to drag and calling it there as well, but nothing seems to work.
Does Detect Drag if Pressed require a specific Pointer Event, like a Mouse Event? Or does the Return Value need to be connected to a mouse event’s Event Reply return?
If so, is there a way to handle the click used to end the drag and drop as an onMouseButtonUp, and use *that *event to start a new drag? The onDrop event seems to consume that input, so I can’t think of a way to do that.
Just creating a new Drag and Drop Operation during the onDrop event (Or during the Destruct event in the drag visual of the old drag) doesn’t do anything either, probably because onDragDetected isn’t being called.

Can anyone clear up exactly what is needed to start a new Drag and Drop operation? I’ve been trying different things for a couple days now, and I’m starting to run out of ideas. :confused:

Last update!

For anyone looking to do this (Or something like it), the editor’s built-in drag-and-drop doesn’t seem like the way to go. I did this by having the item create a copy of itself which follows the mouse after clicking on it, using a simple function to set its position each tick.
Then the inventory goes through each item widget, and finds the one set as the dragged copy. If dragged copy is within the area of the inventory grid, it checks the slots in the area where the item would be placed for another item.
Clicking again sets a bool within the dragged copy which is read by the inventory, which then decides where to place the item or whether to create a new one (if the item wasn’t already in the grid).
Nothing happens if there are multiple items in the way (the item returns to where it was), but if there’s only one it places the held item and calls the function to create a new dragged copy of the blocking item.

By the way; the items (when they aren’t being dragged) and inventory slots are within the same Grid Component, on different layers. The slots are a set size, which forces the grid’s rows/columns to be uniform, and the items are assigned row/column positions and spans when they are placed or created.

Hopefully that helps anyone who stumbles on this thread and wants to reproduce something like this using UMG! :smiley: