Parsing an InputEventMouseButton event results in infinite loop

Godot Version

v4.2.1.stable.official [b09f793f5]

Question

I try to intercept my mouse click in one place, and make the real click happen in another place. For that I use a Control node to collect the InputEventMouseButton event and create a new one with different position.
But when I parse the new event, infinite loop happens.

Here is a demo. ClickProxy node covers upon Button1 to intercept click:

Script on the Test2 node:

extends Node2D

func _on_button_1_button_down():
	print("1 clicked!")

func _on_button_2_button_down():
	print("2 clicked!")

func _on_click_proxy_gui_input(event):
	if event is InputEventMouseButton and event.is_pressed():
		var ev = InputEventMouseButton.new()
		ev.pressed = true
		ev.button_index = MOUSE_BUTTON_LEFT

		# Button2 is 100px to the right of Button1
		ev.position = event.position + Vector2(100, 0)
		
		Input.parse_input_event(ev)

When I click on Button1, I expect the real click land on Button2. But infinite loop happens.
I test it a bit to find out that my new event is also intercept by ClickProxy node. But how is that possible? Since the position of the new event is outside of Button1.

Can someone explain why, or point me to some doc or working demo, thanks!

I believe, that this was fixed for Godot 4.3. Please try updating your version.

1 Like

You are right, it works in Godot v4.3.stable.official [77dcf97d8]. Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.