problems with InputEventScreenDrag and dragging and droping 2d items

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

I am developing a mobile game, i have a button with a 2d sprite as a child, when the user:
-single tap = it opens a dialog window
-double tap = buys character (not implemente)
-drags = grabs the sprite and moves it with the cursor, if it is relased in the wrong place it goes back to the original positon… the problem is that when, this happenes, it wont let me drag it again, unless I do a single tap first… i have no idea why… the most i have figuered out is that its not detected the “enter focus signal”, once the sprite is returned to its original place.

extends TextureButton
#var for activating drag
var drag = false
var focus = false
var placed = false
var original_pos = Vector2(0,0)

#var for characters
onready var char_obj =  preload("res://Scenes/Unit.tscn")

func _ready():
	original_pos = get_node("overlay_cont_0/char_holder_0").position
	pass

func _input(event):
	if event is InputEventScreenDrag:
		#sets dragging on and check to see if the button is the focus
		drag = true
		if focus:
			print("Drag")
			get_node("overlay_cont_0/char_holder_0").position = event.position

func _on_Shop_butt_0_button_down():
	pass

func _on_Shop_butt_0_button_up():
	if !drag:
		get_node("../../../Stats_panel").show()
	drag = false
	focus = false
	if !placed:
		get_node("overlay_cont_0/char_holder_0").position = original_pos
	
func _on_Shop_butt_0_focus_entered():
	focus = true;
	print("Here")