godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.64k stars 20.1k forks source link

InputEventMouseMotion not sending to proper control #94283

Open EmilyV99 opened 1 month ago

EmilyV99 commented 1 month ago

Tested versions

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

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

kitbdev commented 1 month ago
EmilyV99 commented 1 month ago

ah, thank you! That thread had the fix I needed. (mouse_entered should in fact do the trick fine, and this issue was already fixed for that event)