Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate input events on TabContainer _gui_input() and _input() #91987

Open
spoutnickgp opened this issue May 15, 2024 · 0 comments
Open

Duplicate input events on TabContainer _gui_input() and _input() #91987

spoutnickgp opened this issue May 15, 2024 · 0 comments

Comments

@spoutnickgp
Copy link

spoutnickgp commented May 15, 2024

Tested versions

  • Reproducile in: v4.2.2.stable.official [15073af]

System information

Godot v4.2.2.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3090 Ti (NVIDIA; 31.0.15.4629) - Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (16 Threads)

Issue description

There seems to be an issue with the TabContainer specifically:
all mouse clic input events are duplicated when calling _gui_input, and are sent twice as two separate events:

  • one with local coordinates of the control in the _gui_input method, as expected
  • the other one with global coordinates, caught afterwards by another node in its _input() method

This happens even with the mouse filter set to stop, and even when using accept_event() explicitly (which should not be required anyway if I understand correctly).

Steps to reproduce

  • Setup a project with a "select" input action bound to left mouse button
  • Have a Sprite Node with the following script:
func _input(event: InputEvent):
	if event.is_action_pressed("select"):
		print(event)
  • Have a canvas layer node, with a child tab container, and a TextureRect control
  • Have the following script attached to the TextureRect control
extends TextureRect

func _gui_input(event: InputEvent):
	if event.is_action_pressed("select"):
		print(event)

This gives the following layout:

  • Set the node mouse filter to STOP

image

  • Click on the Background node: the function _input is called with an input event as expected
  • Click on the texture rect: the function _gui_input is called, as expected, but the the function _input is also called from the Sprite Node with a different input event matching the first one except the coordinates are translated.

The behavior is the same with _unhandled_input() and event with explicity acquitance of the input event with accept_event() (which is logical if these are two separate events).

Expected behavior:

  • Only one event is sent in the child of the TabContainer's _gui_input method, with no duplicates.
  • This "proper" behavior is seen in all other tested container nodes, only the TabContainer seems at fault.

Minimal reproduction project (MRP)

godot-tab-input-bug.zip

@spoutnickgp spoutnickgp changed the title Duplicate input events on TabContainer _gui_input() Duplicate input events on TabContainer _gui_input() and _input() May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants