Drag and Drop

Hello guys,
Do you know how can i move this widget, so it dont duplicate, and it drags the actor under it with this widget?

Feed the widget you drag as payload:

When you drop, add payload to a new container:

Since a widget can only have a single parent ( :cry: ), it will be reparented.


it drags the actor under it with this widget?

In the graph I posted there is a note about associating an actor with a widget - you can bind those two together.

You’d need to detect drag as before but use onMouseMove in map canvas to generate a coordinate, you can then update the widget’s actor.

3 Likes


So i need to use this example?
if i understand you right

and it drags the actor under it with this widget?

Assuming you want to update the actor every frame as you drag (rather than only when you re-drop), the generation of the coordinates will be identical for moving and dropping the widget about.

You can use the existing method - it’s at the bottom of the graph I posted above. You will still want to trace as you move the widget, as you may move it over a mountain.

Yep, it updates every frame but spawns actor each time i move and i drop it, is there a method an actor can move with this widget too?

While there are many ways of doing it, here’s how I would handle it. This example only covers the onDrop update. (if I find the time later on, I’ll try to post the onMouseMove solution as well).

  • in the waypoint actor, the widget is going to bind an Event Dispatcher to this custom event:

image

  • in the waypoint widget; an Event Dispatcher taking a location vector and an additional bool keeping track of whether we need to spawn an actor for this widget:

  • when dropped, the payload is added to the canvas, we keep a local reference for later:

  • the rest of the same graph:

  • dropping for the first time, reparents the widget and spawns a new actor, further drag & drops simply reposition the existing one:


But again, I can think of a number of ways of handling it. If you’re ok with hard references, you can create one in the widget and feed it the spawned actor.

2 Likes

Yo man thank you once again, you’re my personal angel or god of unreal engine. So much easier to learn

Hey sorry, one more detail, how can i do the waypoints infinite, so i can drag them over and over again?

They are already infinite. It’s the same waypoint widget that you drag again and again. Unless your implementation differs from mine.

Hey sorry, one more detail, how can i do the waypoints infinite, so i can drag them over and over again?

Or do you mean that you want to have a waypoint on the side and then place any number of copies of it on the map?


Do you know how can i move this widget, so it dont duplicate,

I guess I might have misunderstood you; you do want to duplicate the widgets but you do not want those duplicates to spawn more than 1 actor to represent them - is that correct?

yep, this “heart” waypoint on the right needs to be infinite so i can drag them to the map as more as i want

Then create widgets as I did before, rather than reparent existing ones.

Do you know how to make this widget or icon stay where actor stays or make it invisible when i zoom in?

Those widgets need to be a part of the widget that is being moved / zoomed.

Zooming or panning is generally done by nesting a canvas within another canvas and shifting the inner one around - not that dissimialar to dragging.

Remember me nagging about adding widgets to a canvas? I think I even mentioned moving the whole thing at that point - that’s how I would approach it.

The waypoints would need to become children of the container that being transformed.


I have a thread about zooming and moving a map out there, with a project attached. May be worth a look at in case you get stuck.

CAn you send me a link pls

And how can i make this widget part of it?

Add the waypoint to the canvas.


i thought its already added

Are you using this canvas to perform the zooming? Probably not.

A lot would also depend on how the zoom/pan is being done.

its inside my main widget, i need add to the canvas in this area?