Drag & Drop attach to Grid Panel (UMG)

Hey everyone! So I’m creating a simple spider solitaire game, and I would like to know how to, when I drop a widget it would attach to the grid panel (location (rows, columns) would be based on the mouse position).

I tried to make it working, but it will not even attach to the grid.

Any ideas would be really helpful.

Thanks

You could derive the coords mathematically but a much more flexible & future-proof approach would be to populate the grid with user widgets. Think of those widgets as slots where another, dragged widget can be deposited.

Here, it would be the slot widgets’ job to detect the drop while the grid simply holds the slots. You could actually skip the grid widget altogether and simply place slots in a grid-like pattern…

As a bonus, you could now have a uniquely shaped grid without any need for laborious coord calculation. And each slot can handle the desired behaviour, including dragged UI element interaction.


I tried to make it working, but it will not even attach to the grid.

If you prefer to carry on this way, perhaps you could show the offending, misbehaving script. I am assuming you’re using this somewhere, right:

image

1 Like

Yes, I’m using it. I’ll try the slots method. Thank you so much for your time and reply.

Hey ! Really sorry for digging this post up, but I’m new to unreal and would like to replicate this system.

Could anyone explain to me how to handle the following approach ?

Thanks !

  • create a user widget that represents a slot
  • populate the grid with those slot user widgets
  • the onDrop functionality will be implemented in that widget

This is no different from any other inventory, tbh.

Okay, I will give it a shot,

Thanks a lot for your answer !