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

gui_input not being called if the touch starts on another control #83465

Open
axvemi opened this issue Oct 16, 2023 · 7 comments
Open

gui_input not being called if the touch starts on another control #83465

axvemi opened this issue Oct 16, 2023 · 7 comments

Comments

@axvemi
Copy link

axvemi commented Oct 16, 2023

Godot version

v4.2.dev4.mono.official [549fcce]

System information

Windows 10

Issue description

Let's assume this setup.

You have two control nodes, with the same script. This script listens to the gui_input event signal.
Holding the touch/click. If you start your touch/click on an empty space, it will call the method when hovering over the control node, but, if that touch/click starts on top of one of the control nodes, it will not get called.

I have checked the other workarounds like checking if the point is inside the control area's and checking mouse enter exit. But at least in my case that wont work because:

-Two control areas can be overlapping, so the one at the top should win
-On mobile on_mouse_enter does not trigger

Is this by design? Or is it an error? If it's by design, what is the expected solution?

Steps to reproduce

2023-10-17.08-52-18.mp4

Minimal reproduction project

MRP.zip

@Calinou
Copy link
Member

Calinou commented Oct 16, 2023

Using TouchScreenButton instead of Button is recommended for proper touch button handling until godotengine/godot-proposals#3976 is implemented.

@axvemi
Copy link
Author

axvemi commented Oct 16, 2023

This applies to all Control nodes, not only buttons.
Also, it happens on the PC version too, if you click on one Control, and holding the click move the mouse to another, it won't trigger the on_gui signal

@Calinou
Copy link
Member

Calinou commented Oct 16, 2023

Also, it happens on the PC version too, if you click on one Control, and holding the click move the mouse to another, it won't trigger the on_gui signal

This is fixed for the mouse_entered and mouse_exited signals since 4.1: #20881

Which on_gui signal are you referring to? There is no single signal named on_gui.

Please upload a minimal reproduction project1 to make this easier to troubleshoot.

Footnotes

  1. A small Godot project which reproduces the issue, with no unnecessary files included. Be sure to not include the .godot folder in the archive (but keep project.godot).

    Drag and drop a ZIP archive to upload it. Do not select another field until the project is done uploading.

    Note for C# users: If your issue is not Mono-specific, please upload a minimal reproduction project written in GDScript or VisualScript. This will make it easier for contributors to reproduce the issue locally as not everyone has a Mono setup available.

@axvemi
Copy link
Author

axvemi commented Oct 17, 2023

Added a video explaining it, and a MRP. It's on the .NET version since I had some trouble trying to translate the lambda to GDScript.

Which on_gui signal are you referring to? There is no single signal named on_gui.

My bad, the signal was "gui_input" on the Control node

@lpares12
Copy link
Contributor

lpares12 commented Apr 9, 2024

Hitting this issue too on PC.

Basically, I'm tring to see which PanelContainer the mouse click is released at.

I have two PanelContainers next to each other. If I click on one and move the mouse to another one, the gui_input event is not triggered in the second PanelContainer, only the first one, despite get_viewport().set_input_as_handled() not being called.

Maybe this is the expected behavior and I missed it. If so, I don't see any way of having this behavior currently.

@Gastronok
Copy link
Contributor

Gastronok commented Aug 7, 2024

Also having this issue on PC:

func _ready() -> void:
	for i : int in pow(%GridContainer.columns, 2):
		var tile : Control = Control.new()
		tile.name = str(Vector2i(i / %GridContainer.columns, i % %GridContainer.columns))
		tile.custom_minimum_size = Vector2(16, 16)
		%GridContainer.add_child(tile)
		tile.gui_input.connect(_detect.bind(tile))

func _detect(event : InputEvent, tile : Control) -> void:
	if event is InputEventMouseMotion:
		print(tile.name)

If the mouse is not held, the name of the tile currently under the mouse is printed.

If you hold the mouse down then it will always print the name of the tile that was clicked on, regardless of where the mouse currently is.

@kitbdev
Copy link
Contributor

kitbdev commented Aug 12, 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

5 participants