godotengine / godot

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

Inconsistent Control node `gui_input` detection #93664

Open beamer159 opened 1 week ago

beamer159 commented 1 week ago

Tested versions

System information

Godot v4.2.2.stable - Windows 10.0.22631 - GLES3 (Compatibility) - NVIDIA GeForce RTX 2070 SUPER (NVIDIA; 32.0.15.5599) - AMD Ryzen 5 3600 6-Core Processor (12 Threads)

Issue description

Control node gui_input detection does not behave consistently with the documentation. The docs state this function won't trigger for various reasons, though two of these reasons are of note:

I made a test project to test this:

Example

This example works as follows:

This example shows the following unexpected behavior:

  1. When the mouse clicks outside the "drop" element, moves onto the element, and then releases the button on the element, the mouse release is not detected. Note that mouse motion is detected in this case, which I expected, but is inconsistent with the button release not being detected.
  2. (Not shown in video) When the mouse clicks on the "drop" element, moves off the element, and then releases the button outside the element, the mouse is release is detected. Additionally, mouse motion is detected outside the element while the mouse button is pressed, which I did not expect, but is consistent with the button release being detected.
  3. When the "draggable" element is clicked and its mouse_filter is set to IGNORE, the "drop" element no longer detects the mouse motion mentioned in (1).

Steps to reproduce

Run the MRP and perform the steps described above.

Minimal reproduction project (MRP)

Test.zip

kitbdev commented 1 week ago

Can reproduce in 4.2.2 and current master v4.3.beta.custom_build [cae2f853d].

For 3, It looks like the mouse focus isn't being changed when the mouse filter changes after the control gets the mouse focus. As a workaround, you can try hiding and immediately showing the Control when changing it to IGNORE, or using grab_click_focus() on another Control.