Skip to content

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

Closed
@xynanlee

Description

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

Activity

AThousandShips

AThousandShips commented on Apr 29, 2024

@AThousandShips
Sauermann

Sauermann commented on Apr 29, 2024

@Sauermann
Contributor

bisected to #67791

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

self-assigned this
on Apr 29, 2024
added this to the 4.2 milestone on Apr 29, 2024
Sauermann

Sauermann commented on Apr 29, 2024

@Sauermann
Contributor

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?

9 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Godot 4.2: mouse_entered will not trigger after GUI Disable Input toggled in SubViewport · Issue #91320 · godotengine/godot