Issue with GUI input events for dynamically created arrow buttons

Godot Version




I’m encountering a problem with triggering GUI input events for arrow buttons that I’m creating dynamically in my Godot project. The buttons are correctly displayed and the mouse_entered event is firing as expected, but the gui_input event isn’t being triggered when I click on the arrows.

Here’s a summary of my setup:

  • I’m using a Control node as a container for each arrow.
  • The arrow itself is a Polygon2D node added as a child of the container.
  • I’ve connected both gui_input and mouse_entered signals to the container node.
  • The container’s size is set to accommodate the arrow’s dimensions.

Here’s the relevant code snippet:

	# add arrows around the board
	for col in range(board_size):
		var arrow_container =
		#arrow_container.mouse_filter = Control.MOUSE_FILTER_STOP
		arrow_container.position = Vector2(col * (cell_size + cell_spacing) + 50, -30)
		arrow_container.size = Vector2(100, 100)

		var arrow =
		# draw a simple arrow
		arrow.polygon = [Vector2(0, 0), Vector2(20, 0), Vector2(20, 10), Vector2(30, -5), Vector2(20, -20), Vector2(20, -10), Vector2(0, -10)]
		arrow.color = Color(1, 1, 1)
		arrow.scale = Vector2(2, 2)
		arrow.rotation_degrees = -90
		# arrow container should be the same size as arrow

		arrow_container.connect('gui_input', func(): 
			print('does not get called')

		arrow_container.connect('mouse_entered', func():
			print('gets called')

		# create that arrow clickable and move the column

It could be that gui_input passes an event parameter and your lambda function does not take a parameter. The function signature is wrong so it probably isn’t connecting or failing to find a compatible function during the signal.

Mouse entered works because it has no parameters, and your lambda matches that.

Ah you are correct. Thank you :slight_smile: