godotengine / godotengine/godot
InputEventMouseMotion not sending to proper control
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducable in v4.2.2.stable.official [15073afe3]
### System information
Godot v4.2.2.stable - Windows 10.0.19045 - Vulkan (Mobile) - dedicated AMD Radeon RX 6600 (Advanced Micro Devices, Inc.; 31.0.12027.9001) - AMD Ryzen 5 3600 6-Core Processor (12 Threads)
### Issue description
I'm trying to implement a simple Sudoku grid. Each Cell is a node, and on clicking it, it takes focus. This works fine. It also has custom keyboard input managing to change the focus to other cells with arrowkeys. This also works fine. (Also, multiple cells can be "selected"- focusing a cell selects it, and they are unselected when another cell is focused UNLESS shift is held)
Then I went to implement selecting multiple cells via mouse drag. When I click on a cell, it gets the click event, and takes focus. Then I drag the mouse, and that cell gets Motion events. But if the mouse cursor goes to other cells, that same one cell is still getting all the motion events.
My first thought was "can non-focused cells not get events like that? huh". Except then I happened to try clicking on a cell, holding, and pressing Alt+Tab to switch windows to another window and back (without releasing the mouse at any point). Upon the window coming to the front again, the Motion events fire on whatever node is being hovered over, not only the focused cell. The fact that Alt+Tabbing out and back in changes the behavior here seemed really weird, and definitely points to some sort of bug being here. (Also, it is not just pressing `Tab` changing the focus- pressing only tab unfocuses the cell (as there is no `Next Focus`), but that same cell, even unfocused, is still the only cell to get the Motion events!)
Looking through issues, I didn't see anything that sounded specifically like this; though possibly related to #77246 ?
### Steps to reproduce
Not sure how to pull out a reproducable section, so, I'll just link my repo (at a specific commit to ensure it remains reproducable): https://github.com/APSudoku/APSudoku/tree/abe60141b363d26b9d94200e094f3bd81496415b
- Launch, go to the Sudoku tab
- Click on a cell, it gains focus (drawn in red), and gains selection (blue border, but drawn behind the focus indicator)
- Drag over other cells while holding click. The most recently hovered cell SHOULD be red and have focus, while every other cell SHOULD remain "selected" - however, this does NOT occur as it should, and instead the originally clicked cell gets all the InputEventMouseMotion, thus nothing else gets selected/focused.
- While holding click still, Alt+Tab to another window, Alt+Tab back. Suddenly, it functions as it should.
### Minimal reproduction project (MRP)
as I said above, not sure how to pull it out much more without a bunch of work. Project is at https://github.com/APSudoku/APSudoku/tree/abe60141b363d26b9d94200e094f3bd81496415b
Contributor guide
Research direction
Run the linked APSudoku minimal reproduction at commit abe60141b363d26b9d94200e094f3bd81496415b9d and follow the Sudoku tab steps, focusing on InputEventMouseMotion dispatch while dragging between cells. Trace the Godot input path involved in focused and hovered controls; done when motion reaches the currently hovered cell during the drag without requiring Alt+Tab.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, godot
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100