# Reset widget slot position when placed wrong.

**URL:** <https://forums.unrealengine.com/t/reset-widget-slot-position-when-placed-wrong/480796>\
**Category:** UI\
**Tags:** drag, drag-and-drop, reset-to-default, unreal-engine, Widget, question\
**Created:** [March 24, 2021, 8:41am UTC](https://forums.unrealengine.com/t/reset-widget-slot-position-when-placed-wrong/480796 "2021-03-24T08:41:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![olga\_p](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@olga\_p](https://forums.unrealengine.com/u/olga_p)\
**Post date:** [March 24, 2021, 8:41am UTC](https://forums.unrealengine.com/t/reset-widget-slot-position-when-placed-wrong/480796/1 "2021-03-24T08:41:01Z")

</div>

![333400-dd.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/a/6/9a60ac3512d2202bb1a9e7337a3cb0f4edca9526.png)

So, I’m trying to figure out how drag and drop works. As seen in the picture I have a horizontal box where I drag from and a box where I drop. I want for example the blue square only be accepted if it’s dragged on blue and so on, if other color is dropped on blue, make it go to its initial position. And this is what I can’t figure out how to do. How do I achieve that? Thanks.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 24, 2021, 9:30am UTC](https://forums.unrealengine.com/t/reset-widget-slot-position-when-placed-wrong/480796/2 "2021-03-24T09:30:08Z")

</div>

Each square needs to be a user widget and carry a flag (index, enumerator, nametag). If you have 4 - enums, if you have 40 - nametag, if you have 4000 - indexes). Each use widget implements onDrop:

When you start dragging, don’t remove the widget from its original position, hide it instead and create a visual for the drag OP. When dropping (or drag enters), query the IDs:

 ![333415-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/6/d/96d169edd8d740659ed2f7eaaf4868e278ec9108.jpeg)

Compare the IDs:

- if they match, reparent the payload into the new container - this will automatically remove the widget from its old parent as it cannot be in 2 simultaneously, return `True`.

- if the IDs do not match, unhide the original widget (it did not even move, it was just hidden) and return `False` to cancel the drag OP.

* * *

> make it go to its initial position

Essentially, smoke & mirrors. Nothing moves until you know you _can_ successfully drop, if you can’t drop, nothing was moved so there’s nothing to return to initial position as it has always been there.

* * *

Also, have a look at my answer here, the one with wires:

> **[Among Us drag and drop mechanic?](https://forums.unrealengine.com/questions/988317/among-us-drag-and-drop-mechanic.html)**
>
> Hello everyone i was wondering how can i achieve the mechanic of connecting wires using just widgets? Right now i got six widgets: 3 on the left side of the screen the others are on the right side. So i need to connect them using some cable, wire or...

The link to the project is still up.

---

<div class="post-metadata">

**Author:** ![olga\_p](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@olga\_p](https://forums.unrealengine.com/u/olga_p)\
**Post date:** [March 24, 2021, 9:56am UTC](https://forums.unrealengine.com/t/reset-widget-slot-position-when-placed-wrong/480796/3 "2021-03-24T09:56:53Z")

</div>

Thank you, I’ll give it a try later and let you know if that works.

---

<div class="post-metadata">

**Author:** ![olga\_p](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@olga\_p](https://forums.unrealengine.com/u/olga_p)\
**Post date:** [March 24, 2021, 12:54pm UTC](https://forums.unrealengine.com/t/reset-widget-slot-position-when-placed-wrong/480796/4 "2021-03-24T12:54:41Z")

</div>

Thanks, it works. I was not setting it back to visible when the color did not match. Now it works perfectly!
