May found a bug or missbehaviur could someone help me out? [Area2D + TextureRect] screenshots.

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

So in my last question in this Q&A(just look the node tree), I was confused why it didn’t work, now I made only a scene with the bare minimun nodes to replicate the other issue, and I found out that the TextureRect I have, blocks que collisionshape in some sort of weird way, my intention was to drag a card around the screen, I used TextureRect because I do not have sprites that fit into the box and texturerect does that job for me, well, after attaching the Area2D to itself with the signals mouse in/out and in it’s script:

extends Area2D
	
var mouse_in = false
	
func _process(delta: float) -> void:
	if mouse_in && Input.is_action_pressed("left_mouse_click"): #This works smoother instead of the Input.is_mouse_button_pressed() idk why

		self.position = get_global_mouse_position()
func _on_Carta_mouse_entered() -> void:
	mouse_in = true
	
func _on_Carta_mouse_exited() -> void:
	mouse_in = false

In other words, what I’m trying to achieve is move a node that has an Area2D + CollisionShape2D + TextureRect(Same size as collisionshape) and be able to click and drag the node/card through the screen. It has something to do with the TextureRect for sure but I can’t find what is going on.

Also add debug prints in the code signals and you will found out that they only execute when clicking and holding the mouse, then drag inside the area, and then release the click, which results in a IN OUT print at the same same time.

Screenshot of the code: enter image description here
Screenshot of the scene: enter image description here

:bust_in_silhouette: Reply From: haledire

What your experiencing has to do with this:

Specifically with the event handling heirarchy:
Hierarchy of event handling, read left to right.

Because the TextureRect is covering the Collision2D, it runs a test for Control input first, then runs unhandled_input and winds up setting the event to handled, blocking the event from propogating to the Collision handling expected below it. If you turn the mouse filter on all of your Control based nodes (everything with green icons, the TextureRects and the Labels) to false, it should ignore the event entirely and let you interact with the Collision2D.

Thanks, didn’t know about the order of events, changed that to false and it worked great. ^^

MaximoTG98 | 2020-04-14 21:10