I’m making a drag & drop inventory and when I drop an item to another slot sometimes a drop function fires and other times drag cancelled event fires randomly. Am I ‘dropping’ the wrong way? What’s the difference between these two?
The OnDrop delegate fires whenever the operation is successfully dropped on a widget that implements the OnDrop method. Keep in mind, you have to return true in that method.
The OnDragCancelled delegate fires whenever any part of the above sequence fails. If what it’s dropped on does not have the OnDrop function, or if that function returns false, this delegate will be called.
Well, about the successfully dropping part, what does UE consider a ‘successful drop?’ I think I’m successfully dropping the widget, but apparently the engine disagrees. I’ve double checked to return true in the ondrop method. I’ll post a video to describe the problem better.
I see. It’s likely a collision issue rather than a drag drop issue. There’s probably something hit-testable, but not visible on top of your items. Could you send a screenshot of your widget and OnDrop/OnDragDetected methods?
here’s the widget:
ondragdetected:
ondrop:
I’ve suspected about the collision thing at first too, that’s why I made the slots go pink in the ondragover method.
And you’re sure that the cast to player never fails?
Can you try disconnecting everything in the OnDrop function, and just have it immediately return true? Though don’t forget to print when it gets in there. I want to see if perhaps something is happening with the update inventory function.
Also, you are supposed to create a duplicate widget for the drag visual.
immediately returning true didn’t work, but creating a widget for the drag visual worked! I was being lazy and tried to just use the image to use in place for the visual but that seems to mess up the collision I guess. Thanks for the help!
No problem! I’m glad we could eventually get to a solution.