Tree control is not having its _get_drag_data method called

Godot Version

4.2.1

Question

I’m implementing a tree control and would like to be able to drag and drop portions of it to rearrange the tree. As far as I can tell, the only thing I need to do to enable dragging from within my control is to override the _get_drag_data method. But this method is never called, even if I click and drag on one of the children within the tree. Is there something else I need to do to be able to start a drag from my tree?

	
func _get_drag_data(at_position:Vector2)->Variant:
	print("_get_drag_data")
	
	var item:TreeItem = %Tree.get_item_at_position(at_position)
	if !item:
		return null
	
	var tier:TestTreeDataModel.Tier = node_map[item]
	
	var label:Label = Label.new()
	label.text = tier.name
	set_drag_preview(label)
	
	return tier.get_parent()

var item:TreeItem = %Tree (...)

Seems like you didn’t implemented the _get_drag_data on the tree node but in a node that has it as child somewhere. This node is the one that must handle the click input, so it should have mouse_input to pass or stop and other node should not handle this input first

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.