[UMG Tutorial] How to create Dragable Windows

Hi,

i’ve clicked together some stuff to show how you could implement moveable windows in your game. (Also manages ZOrder)
the code isnt really documented but it should be easy enough to understand. If you have any questions dont hesitate to ask them.

This BP stuff can be used as a canvas. Use the DragableWindowWidget to attach some childs to it so you wont have to deal with rewriting the drag logic over and over for every window your game has

EDIT: Important this does not contain a map, you need to create a customgamemode and add the DragDropController as the default playercontroller to get this demo working.

Oh and a little sidenote. You can use the technic i used to determin the mouse position in the viewport (fullscreen or windowmode) to get fullscreen dragdrop stuff working

Download:
https://www…com/s/buutnfmjwwzz6zi/DragableWindows.zip?dl=0

Will save people a some time and effort.
Very useful.
Thank you.

Thanks mate! Really useful for Inventory system. :slight_smile:

Awesome, thanks !

This example has been very useful so far. I’m finally starting to get a grip on how stuff works in UMG. I’ve noticed one issue, the example you’ve created works well in PIE and in New Editor Window, but it doesn’t work in Stand Alone Game. The mouse cursor doesn’t pick up the widgets and instead controls and rotates the camera.

Do you have any idea why this is happening?

Thanks,

Thanks a lot , your projects are really helpful.

This is very helpfull indeed thanks for the share.
IF i may be so bold to ask for more comments next time that be great.
Thanks again and have a happy new year! :slight_smile:
Cheers!

try to cook content first sometimes it helps

Is there a written version of this somewhere?
Thanks again.

written version? like commented? well ill put down some coments and post an update :slight_smile:

Changed the thing, everything is commented now. :slight_smile:

Thanks for the commented version. I didn’t really understand all the mouse events when I first used the non-commented version of this :slight_smile:

One question though, why is this Slot as Canvas Slot and not Border Slot, since the first child in the widget root is a Border Slot? By “OuterParent” are you referring to the actual root of the widget? So the root in UMG is always a canvas slot?

Thank you that is realy nice of you! ★
Cheers!

Thank you

I love you for this. That trick with use the parents geometry has changed my unreal life. I am using this method in a inventory system i am working on!
Thank you so much !

heh you are very welcome :slight_smile:

the Slot as Canvas Slot will grab the Canvas in the Parents Space. Since the Direct parent is a Canvas, the widget is inside a Canvas Slot, we also dont want to move the widget itself because the only way we could do that is the translation, we move the parent slot

Hey there , I gave this a go. The demo works fine in 4.6.1 but when I follow along and make my own version as 1-1 it crashes on dragging. Which version was this made in ?

Thanks for this

I had the same crash but found a work around by moving the code in GetMousePositionInViewport to OnMouseMove itself.

I also submitted a bug report regarding the issue. [bug?] UMG Dragable Window Crash - Programming & Scripting - Epic Developer Community Forums