You can do something like this without an area.
extends Node2D
var but:Button
var but_rect:Rect2
var follower:Sprite
var lab:Label
var tim:Timer
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion \
and but.pressed \
and not but_rect.has_point(event.position):
if not follower:
follower = Sprite.new()
follower.texture = preload('res://icon.png')
add_child(follower)
follower.position = event.position
elif event is InputEventMouseButton \
and not event.is_pressed() and follower:
follower.queue_free()
follower = null
func _ready() -> void:
but = Button.new()
but.rect_size = Vector2(100, 40)
but.rect_position = Vector2.ONE * 100
but_rect = Rect2(but.rect_position, but.rect_size)
add_child(but)
but.connect('pressed', self, 'but_press')
lab = Label.new()
lab.rect_scale = Vector2.ONE * 5
lab.rect_position = Vector2(100, 200)
add_child(lab)
tim = Timer.new()
tim.one_shot = true
tim.wait_time = 1
add_child(tim)
tim.connect('timeout', self, 'tim_out')
func but_press():
lab.text = 'pressed'
tim.start()
func tim_out():
lab.text = ''