# GraphNode.gd extends Node2D @onready var label: Label = $ColorRect/RichTextLabel var node_id: String = "" var velocity: Vector2 = Vector2.ZERO var is_dragging: bool = false func setup(id: String, node_name: String) -> void: node_id = id if not is_inside_tree(): await ready var target_label = get_node_or_null("ColorRect/Label") if target_label != null: target_label.text = node_name func _process(_delta: float) -> void: if is_dragging: # Follow the mouse smoothly while dragging global_position = get_global_mouse_position() velocity = Vector2.ZERO # Stop physics movement during drag func _input(event: InputEvent) -> void: if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT: if event.pressed: # Check if the click is inside our 150x50 ColorRect boundaries var local_mouse_pos = get_local_mouse_position() # Assumes your rect position is at default (0,0) or centered. # This checks a standard 150x50 area relative to the node origin: if local_mouse_pos.x >= 0 and local_mouse_pos.x <= 150 and local_mouse_pos.y >= 0 and local_mouse_pos.y <= 50: is_dragging = true get_viewport().set_input_as_handled() # Prevent dragging multiple nodes else: is_dragging = false