Hi, I’m stuck with a UI problem. I try to use the built in drag and drop feature from control object. I already done it before and it work well. In my current project I don’t know why, I can start dragging an object but cannot trigger the _CanDropData and _DropData function when I’m hovering the destination UI control.
I don’t know how to debug and find out which element is blocking the Mouse event but surprisingly the OnMouseEntered and OnMouseExited work fine while dragging.
Here is the tree of my menu and the one from my Item that can be dragged :
My tree looked something like this in my main scene:
Root node
Sub viewport container
sub viewport
instantiated scene
When launching the instantiated scene on its own, drag and drop worked fine. When launching the main scene, the _get_drag_data call would happen just fine, but no _can_drop_data or _drop_data calls would happen. I even found that if I managed to click the same button I was holding down (left click on track pad while holding left click on mouse) I could manually trigger the _can_drop_data and _drop_data calls, but otherwise they weren’t happening.
Long story short, the subviewport was the issue. There is an option under the GUI section of the subviewport settings labeled “Embed Subwindows” that is not checked by default. Checking this box caused the drag and drop of the instantiated scene to work just fine and fixed this issue. I figured I’d leave this hear for anyone else that ran into this niche issue.
TLDR: If drag and drop issues are happening when something is in a subviewport, try enabling “embed subwindows” under GUI in the subviewport node.