Need some help creating a drag and drop system

Need some help creating drag and drop item system, like example in Path of Exile

Essentially if the item is on the world I can click on it (Button) that stop mouse events so that my player wouldn’t do any actions

My problem is that the item is a Button and in external node from the GUI


  • World

    • Item (Button)
  • GUI (Panel)

    • Inventory (Gird)
      • ItemSlot (Color Rect)

I click on item, button consumes an even and everything is fine, I can then move the item while dragging (still a Button) and want to put it in inventory, but the because the Button stop mouse event (even on pass, because it’s kinda outside the hierarchy ) the inventory doesn’t get any mouse entered or exited so I can’t determinate on which slot to put the item when I click on it again

I have it working with Area2D (pickable) when you pick up item it becomes from Button to Area2D as it doesn’t consumes event’s so the Inventory gets all the mouse entered or exited, but I can’t stop the player events let say when I want to drop the item to the world and the player should be still, because it impossible to accept Area2D Input Events

Is there a way to stop events while not in control hierarchy and pass mouse enter and exited, I know if the Item is in GUI → Inventory → ItemSlot → Item it will work fine because mouse passes upwards, but what about when the Item (Button) is outside of the hierarchy

I don’t understand the situation completely,

But is something like this an option?

Btnpos = PackedVector2([Vector2(Button.position),Vector2(Button.position + Button.size)])
Hierarchypoly = PackedVector2([Vector2(Hierarchy.position), Vector2(Hierarchy.position + Hierarchy.size)])

var is_inside1 = Geometry2D.is_point_in_polygon(Btnpos[0], Polygon2D(Hierarchypoly)) 
var is_inside2 = Geometry2D.is_point_in_polygon(Btnpos[1], Polygon2D(Hierarchypoly)) 

If not is_inside2 and not is_inside2:
      pass # Button is not in hierarchy

This code came straight out of my mind, so it’s absolutely not completely right.

But you’ll probably get the idea,

Check if the button polygon is inside the hierachy polygon.

This is a passer by problem. Just use a signal to the Item.
or call functionality of the Item.
It seems strange. But, from GUI you should be able to Item.mouse_entered.emit