User can rearrange their menu

Hey everyone,

As many people, I am trying to teach myself a how to use the Unreal 4 engine. During a lot of testing and playing around with different stuff I came to a problem I can not solve:

How can I let the user change and reorder for example thei hud or the main menu via drag and drop? That would be the first part of the question.

Extended question:
If the user is using drag and drop and is dropping a button on another button for example, is it possible to let the button move away? So different parts of the menu cant overlap with one another?

The first part of the question is the more important one.

Thanks for any help I can get, Cheers, guys and girls! ^^

Hi there!

Drag and drop is created by going into the graph part of the widget blueprint and overriding certain functions. For the main widget these would be OnMouseButtonDown (or onpreviewmousebuttondown), OnDragDetected and . In the sub widgets you are dragging you need to override “OnDropped”. I don’t have the engine in front of me now for the code but basically you want to check if the correct button for dragging is being clicked (LMB for example), you create a drag operation by casting to a drag n drop operation (a blueprint class you create). Sorry if this is confusing. You also need to override “OnDrop” in the dragged widgets and have them recreate themselves (or they will simply disappear when you drop them).

As to the second question: There is something called Z-order which defines how much in the front a widget is. If you exoand the little arrow on “add to viewport” you can see it. Higher means more on top.

And you can make buttons clickable through widgets, if the contents are set to hit test invisible.

These vid will show you how to do this:

1 Like