Why is my click event not being detected?

Godot Version

4.6.1

Question

I’m implementing my version of the Mahjong game for learning purposes and setting up the initial data structures like a base Tile scene that implements a click and a tween to animate its movement. For some reason the only mouse buttons being detected are the mouse wheel up and down.

func _on_input_event(viewport: Node, event: InputEvent, shape_idx: int) -> void:
	print(event.button_index)
	if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
		print("clicked")
		move_to_target()
		
	if event.is_action_pressed("clicked"):
		print("clicked")

I placed that print statement to make sure which event is being triggered and it only shows 4 and 5 (mouse wheel up and down). I even created an Action (“clicked”) in the project settings but also not being detected. I read somewhere that some other point in the game could be overriding the behavior for the clicks but I have no other signals connected in the entire game. Can you help me find where the issue is? the complete code is at my codeberg:

Thank you in advance

Have you checked the “Misc” tab in the debugger, it will show you what nodes your mouse clicks land on?

it is being captured by the main Game scene node’s ColorRect , which I don’t understand why since the Tiles are being added on top of it (in the %TileGrid node)

It may work if you set the color rect’s mouse filter to “Ignore” or “Pass”

1 Like

thanks, that was it