0 votes

Hello Godot community,

I started working with the Drag&Drop built in functionality in Godot.
I got familiarized with

get_drag_data()
can_drop_data()
drop_data()

My question is, is there an event for dropping data elsewhere (I mean by elsewhere, in a zone where the drop_data is not expected), once it's dragged ?

Here is my issue:
I have objects which can exist in 2 containers, these objects implement the drag code:

func get_drag_data(pos):
   ## Preview code here ##
   self.hide()
   return self

I hide the object to give this impression that we picked it up and it's being dragged

The containers (receivers) implement the drop code:

func can_drop_data(pos, data):
    return true

func drop_data(pos, data):
    data.get_parent().remove_child(data)
    data.show()
    add_child(data)

Once dropped, I remove it from the parent, I render it and I add it to the target.

This works perfectly, the only problem is when I drop it elsewhere, I lose the drop event and my object stays in a hidden status in the source.
I would like to show() it back if the drop happens in a zone where it's not expected.

Thank you for your help.

asked May 20 in Engine by Seli (17 points)
edited May 22 by Seli

I didn't find anything in Godot documentation, any ideas ?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.