Im using the drag and drop functionality, I have a horizontal box of items and i need to be able to drag and drop to rearrange them. The drag and drop works perfectly, except the other widgets no longer detect mouse hover events while it is dragging, presumably because the dragged widget is underneath the mouse all the time. I need to be able to find which widget the dragging widget is on top of when it drops.
I found an event called OnDragOver, but it doesnt have a parameter for the current widget component being dragged on at the moment.
I should also note, this is going to be for a mobile game so i cant use the mouse position after the drop.
I’d have the Item’s
onDragEnter (and/or Leave) handle this; unlike the
OnDragOver, it’s more efficient as it fires only once:
The Operation has Payload - that’s the widget you’re dragging, providing that you’ve assigned it when the Drag OP was created.
I found an event called OnDragOver,
but it doesnt have a parameter for the
current widget component being dragged
on at the moment.
Same as above. Get Payload from the Operation → Cast to whatever widget you’re dragging.
I have a horizontal box of items and i
need to be able to drag and drop to
Event Dispatch the dropped item and the item dropped on back to the widget housing the HB and have that widget rearrange its children (which can be somewhat painful…)
thanks for the reply, i dont quite understand though, let me explain a little further what im doing
I have a horizontal box with borders inside of it, when dragging, i have the border being dragged stored in the drag and drop operation, but when i drop it, the on drag over seems to only get the widget, i need to get the specific border underneath the one im already dragging
The closest thing ive found to get it working is to use a timer for .1 seconds and then store the hovered compnent under the mouses location to find the hovered component. this is hit or miss on windows but with android there is no mouse, so that just returns false every time.
is there any way to get the specific border inside the widget being dragged on from the on drag over event? i have a feeling im going to have to store each of the borders in a completely seperate widget and then spawn them in the horizontal box, rather than just having the horizontal box filled with borders. Which is not preferable as ill have to redo all the blueprinting and animations from the widget in each one seperately
is there any way to get the specific
border inside the widget being dragged
on from the on drag over event?
It would need to be a separate widget. There are ways of hacking around it (you’ve got one right there!) but it’s not worth it imho; and it makes for a busy / confusing script you may want to refactor later anyway.
When you deal with ordering items like that, you generally work in the way you’ve just described - you make actual slots that can hold other widgets. These slots have fixed indexes (and enter / leave anims), and children can be moved between them, as seen here:
You seem to know precisely what you’re dealing with here so the only advice I can give is to redo the mechanics into slots. The earlier the better. Just the fact that you cannot reorder children in a widget container might be enough to warrant the extra work.