How do I do Drag & Drop in Slate?

Hey,

I am trying to learn how drag & drop works in slate but can’t seem to figure out how to get it working. I know I need to call the BeginDragDrop function from the FReply but it needs a FDragDropOperation and I can’t figure out how to go about creating it to display an icon on dragging. According to the Unreal Engine 4 Docs for FDragDropOperation it shows sub-classes but I don’t find any of those in the engine source.

Does anyone know how to set up a simple drag & drop in Slate?

https://answers.unrealengine.com/questions/57199/slate-drag-drop.html

For entire implementation (as bad as it is ;p), you can look at my repo. There is basic inventory system implementedm with drag and drop. Though it is not fully working and there are still edge cases where it fails.

Thanks iniside,

I will look into your repo and see what I can learn from it. That answerhub question page is where I learned about how to start and end the drag and drop but not what to pass into the starting of the drag. If I figure out any solutions to the edge cases where it fails I will let you know.

I have gotten it to start the drag :). Still working on the end drag part. However, is there any way to make the drag widget have a transparent background? Having a black background isn’t all that helpful when I want to have the item icons being dragged have some transparency to them. Also the drag widget is not directly centered under the mouse. Is that normal and is there a way to get the drag widget centered under the mouse?

Thanks again iniside, your repo had a good on how to start and stop dragging.

In FSlateBrush, you can use material with transparency or masked mode instead of plain texture. I dunno if that works, but worth a shot.

As for centered object while dragging. I have no idea, i didn’t considered it world breaking, so I havent even checked if it is possible to re position it (;.

Thanks, I will give FSlateBrush a shot and hopefully that works. When I changed the decorator to an almost no alpha red box it turned black and not invisible which I am thinking the black is the background to the decorator. Hopefully there is a way to get it to not have a background color as that kind of limits the possibilities using drag & drop. As for the centering, its not world breaking but would be nice to have it positioned under the mouse to create the effect of dragging lol instead of having it follow the mouse.

Hey can you give me the link to the repo?