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

Godot 4.2: mouse_entered will not trigger after GUI Disable Input toggled in SubViewport #91320

Closed
xynanlee opened this issue Apr 29, 2024 · 4 comments

Comments

@xynanlee
Copy link

Tested versions

Reproducible in 4.2.1-stable and 4.2.2-stable, not in 4.1-stable

System information

Godot v4.2.2.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2070 SUPER (NVIDIA; 31.0.15.3623) - AMD Ryzen 7 3700X 8-Core Processor (16 Threads)

Issue description

mouse_entered signal reside in a StaticBody2D under a SubViewport will not trigger anymore after GUI Disable Input is toggled off and on.

Steps to reproduce

  1. Open the MRP.
  2. Play the scene.
  3. Move mouse cursor onto the Godot logo.
  4. Observe the enter text printed out in the Output panel.
  5. Select Remote at the Scene dock.
  6. Click on SubViewport.
  7. Toggle GUI > Disable Input On and Off.
  8. Repeat Step 3.
  9. No subsequent enter text will be print out in the Output panel.

Minimal reproduction project (MRP)

4.2.2-stable_InputIssue.zip

@AThousandShips

This comment was marked as outdated.

@Sauermann
Copy link
Contributor

Sauermann commented Apr 29, 2024

bisected to #67791

I was unable to reproduce the bug in v4.3.dev.custom_build [6118592] (with MRP adjusted $SubViewportContainer.mouse_filter)

@Sauermann Sauermann self-assigned this Apr 29, 2024
@Sauermann Sauermann added this to the 4.2 milestone Apr 29, 2024
@Sauermann
Copy link
Contributor

Sauermann commented Apr 29, 2024

Very interesting MRP. The MRP works as expected, but the reason is quite complex.

So I start with how to solve your problem:

Instead of pushing the input to the SubViewport within SubViewportContainer._unhandled_input, use the SubViewportContainers default implementation for doing this. There has been some effort to make this more effortless for Godot 4. You can achieve this by two changes:

  1. In GameInstance.gd, remove the function _unhandled_input completely
  2. For the node GameInstance, change the property Control > Mouse > filter (mouse_filter) from Ignore to Stop or Pass.

I remember seeing this kind of implementation for SubViewport-input-propagation as a workaround for bugs in previous Godot versions, that have been fixed since.


Why doesn't your MRP work the way you expect: Toggling gui_disable_input to on has the effect, that the Viewport gets into a state, where it thinks, that the mouse is no longer over it. Toggling gui_disable_input to off afterwards doesn't reset this state.
Also sending a mouse event by gameViewport.push_input(event, true) is not enough to reset the state. So as a workaround you could adjust your _unhandled_input function like this:

func _unhandled_input(event):
	gameViewport.notification(NOTIFICATION_VP_MOUSE_ENTER) # this line is new and causes for mouse events the correct state in the SubViewport.
	gameViewport.push_input(event, true)

But I don't recommend this approach, because this is just a workaround for no longer existing bugs, would need additional refinement and because the other method is the way it is supposed to be used.


Does this solve your problem?

@akien-mga
Copy link
Member

Closing as this works in 4.3, and the issue in 4.2 seems to be intended behavior as per the above comment.

@akien-mga akien-mga removed this from the 4.2 milestone 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

4 participants