Godot Version
4.2.2
Question
Hi
I’m trying to drag and drop controls based on GraphElement from a side bar to the GraphEdit and this works for the most part.
On the dropped controls there is an TextureRect I use for some logic that snaps controls together. What I do exactly is go over all those TextureRects and compare mouse position with their get_global_rect(). This works for the nodes that I already placed in GraphEditor before starting the game but not for those dragged and dropped at runtime.
I narrowed it down to myTextureRect.get_global_rect() returning always zero for controls dropped at GraphEdit. Now is that a bug or maybe I create them the wrong way?
I thought that maybe the way that ‘duplicate’ the control makes it somehow bilocate and sit in same spot on the sidebar as the original one? but the baseControl.myTextureRect.get_global_rect() seems to return correct values.
func _drop_data(position, data):
if _can_drop_data(position, data):
#most likely this is node dragged from palette
#data refers to node still on palette, not the one dragged visually
var graph_node = data.duplicate()
#var graph_node = data.get_script.new() #nope
draggedInNode = graph_node
add_child(graph_node)
graph_node.position_offset = position + Vector2(4,4)
func CheckDockOverlap(mousePos : Vector2):
if Rect2(mergeDetectImg.get_global_rect().position, mergeAreaSize).has_point(mousePos):
return true
else:
return false