godotengine / godot

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

FileDialog unable to be interacted with when launched from PopupWindow #97243

Open popyd10 opened 6 days ago

popyd10 commented 6 days ago

Tested versions

System information

Godot v4.3.stable.mono - Windows 10.0.19045 - GLES3 (Compatibility) - Intel(R) UHD Graphics 620 (Intel Corporation; 25.20.100.6577) - Intel(R) Core(TM) i3-8130U CPU @ 2.20GHz (4 Threads)

Issue description

When launched from a PopupWindow, either directly or via callback, the FileDialog window cannot be closed, moved, or meaningfully interacted with.

Steps to reproduce

In the MRP, click the "save" button to directly launch the FileDialog window (this should work). Click the "save with popup" button to launch a PopupWindow which can launch the FileDialog. This FileDialog exhibits the strange behavior.

Minimal reproduction project (MRP)

FileDialogIssueMRP.zip

WhalesState commented 6 days ago

I can't test this since I'm not using Godot Mono, but this line looks suspicious, since Popup is already a builtin class.

public partial class Popup : PopupPanel

In GDScript it could have thrown an error Class "Popup" hides a native class..

WhalesState commented 6 days ago

I have tried to reproduce the issue in a GDScript version, calling FileDialog from inside a PopupPanel, the only difference in the two projects is that the PopupPanel becomes hidden after showing the FileDialog, but in your project it's always visible. So maybe it's an issue in your CS code, also I have downloaded the Godot Mono version and tested your project, I tried to change the Popup class name to MyPopup but it printed some errors that I couldn't solve.

WhalesState commented 6 days ago

This error is printed. E 0:00:24:0704 window_move_to_foreground: Condition "!windows.has(p_window)" is true. <C++ Source> platform/windows/display_server_windows.cpp:2219 @ window_move_to_foreground()

Commenting this line makes the PopupPanel becomes hidden when the FileDialog become visible, which is fine for builtin FileDialog and I can interact with it. image

WhalesState commented 6 days ago

Also, calling Hide() first fixes the issue. image

bs-mwoerner commented 3 days ago

This may indeed be an issue with the display server. It looks like if there is an active (modal?) Godot popup window, then Godot discards all mouse input from outside that window's screen area. This logic continues to be applied if that popup opens a native dialog window. As a result, the user can only interact with those parts of the native dialog that happen to overlap the popup's screen area.

If the native dialog is opened via the "Save" button in the MRP, then there is no Godot popup and no mouse events are filtered, letting the native dialog see all mouse input and be used normally, even outside Godot's main window.