Stack overflow when trying to move window to mouse position

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By WilliamD47

Hello, I am trying to make a draggable section of my app and am using this code

extends Control


var following = false
var start_pos = Vector2()


func _on_Titlebar_gui_input(event):
	if event is InputEventMouseButton:
		if event.get_button_index() == 1:
			following = !following
			start_pos = get_local_mouse_position()
	
	if following:
		OS.set_window_position(OS.window_position+get_local_mouse_position()-start_pos)

and when I run it, I have to double click the window section and then it crashes with Stack overflow 1024. If anyone could explain this, it would be greatly appreciated. Thanks!