How to grab mouse event after button_down() on a Control.ToolButton ?

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

I am making a card game in which the player should play cards onto certain landtiles via drag an drop.

For this 3 things have to work:

a) The player should be able to move the mouse cursor above the cards in the card hand. Each card under the mouse cursor should the be moved a bit up and zoomed a bit. → for this to work I am using a ToolButton a the card. I tried Area2D with Collision2D, but because of the overlapping cards I am not getting valid mouse_entered and mouse_exited signals.

b) An indicator line should appear after the player clicked on a card and disappear after he relseases the mouse.

c) While the mouse button is down the landtiles a player can play the card onto should be highlighted and they should accept the card if possible.

a) and b) work just fine. c) however I am stuck with.
I tried to implement get_drag_data()onto the card node. That would work, but then my mouse cursor changes as long as I am on the card into a “forbidden sign”. And whats more important: my indicator line does not disappear after releasing the mouse button.
So basically I am looking for a solution how to keep tracking the mouse after i clicked onto my Card (i.e. ToolButton). I also tried to set mouse_filter to PASS, but that didn’t work either. Any other ideas?

I did also insert a screeshot to clarify, but it does not show. url: [1]: Imgur: The magic of the Internet

Klagsam | 2019-11-12 07:52

:bust_in_silhouette: Reply From: Klagsam

Ok, after a good nights sleep I figured this out my self. Here is my solution for other people running into a similar problem:

On my landtiles I have the following code with tileArea being a Rect2:

func _input(event):
	if event is InputEventMouseMotion and tileArea.has_point(event.position) and !cursor_on:
		cursor_on = true
		print (self)
	elif event is InputEventMouseMotion and !tileArea.has_point(event.position) and cursor_on:
		cursor_on = false

My cards are still ToolButtons, but I did only connect the signals for mouse_entered() and `mouse_exited(). Mouse click and release I did implement manually with this:

func _input(event):
	if event is InputEventMouseButton and event.is_action_released("LMB"):
	elif event is InputEventMouseButton and Input.is_action_just_pressed("LMB"):