godotengine / godotengine/godot

Unable to receive InputEventMouseMotion in _gui_input() when pushed to SubViewport via push_input()

Open
#115,265 1 comment 0 reactions 0 assignees View on GitHub
bug topic:gui topic:input
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

v4.6.rc2.official [78c6632eb]
v4.5.1.stable.official [f62fdbde1]
v4.4.1.stable.official [49a5bc7b6]

### System information

Godot v4.6.rc2 - Windows 11 (build 26200) - Multi-window, 1 monitor - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 4060 Ti (NVIDIA; 32.0.15.8088) - AMD Ryzen 9 3900X 12-Core Processor (24 threads) - 31.91 GiB memory

### Issue description

InputEventMouseMotion events sent via `push_input()` to a SubViewport won't reach `_gui_input()` of Controls inside the SubViewport.

Image

I have a SubViewport that contains a scene with some Controls. The SubViewport is then rendered as a ViewportTexture inside a TextureRect.

Image

The TextureRect has a script `event_forwarder.gd` that receives all InputEvents and forwards them via `push_input()` to the SubViewport, which in turn sends the events to its sub nodes. **With the exception of InputEventMouseMotion events.**

InputEventMouseMotion is only getting correctly forwarded while a mouse button is pressed.

**Workaround:**

In `event_forwarder.gd` uncomment the line in `_ready()` that sends one `NOTIFICATION_VP_MOUSE_ENTER` to the SubViewport.

```
func _ready() -> void:
#sub_viewport.notification(NOTIFICATION_VP_MOUSE_ENTER)
pass
```

This issue is related to #89757, which is unfortunately closed.

**What is the problem?**

If I am able to manually forward all other events via `push_input()`, I should be able to send InputEventMouseMotion events as well.

### Steps to reproduce

Image

Move the mouse over the TextureRect on the left. Unless you press the mouse button the coordinates label will stay at "0/0".

For comparison, on the right side is the same setup but using a SubViewportContainer, which works as intended.

### Minimal reproduction project (MRP)

[MRP.zip](https://github.com/user-attachments/files/24794858/MRP.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the MRP and event_forwarder.gd, then trace how push_input() handles InputEventMouseMotion for the SubViewport and its Controls. Reproduce the missing motion updates without the mouse-enter notification workaround; done means motion reaches _gui_input() while the button is released.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.