godotengine / godot

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

(Code-Shown) Popup Menu Makes Ordinary Menu Items Unresponsive #87875

Open chaojian-zhang opened 7 months ago

chaojian-zhang commented 7 months ago

[!IMPORTANT] Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.

Tested versions

v4.2.1.stable.official [b09f793f5] (The issue DO NOT exit on v3.5.2)

System information

Windows 11 Pro - Godot_v4.2.1-stable_win64.exe

Issue description

In Godot v4.2: when summoning a popup and subsequently close it (either by clicking outside, or calling hide()), it will cause all other popups and certain GUI hover event stop working (e.g. it causes it not possible to resize a GraphNode if using a GraphEdit). This issue notably blocks input not just on MenuBar, but also on MenuButton (I suppose it's because they all uses popup window behind the scene). However, if one attempts to summon the popup at the same time performing a typical mouse button click on any menu bar item, the problem goes away; The problem can also be "fixed" if one switches the window (e.g. on Windows, use Alt-Tab), i.e. defocusing then focusing again the Godot application window.

Please see video below for a demo:

https://github.com/godotengine/godot/assets/7077098/b5bac962-a81e-4b08-ad41-928d917ed39f

I CAN CONFIRM THE ISSUE DOES NOT EXIST ON GODOT Godot_v3.5.3-stable_mono_win64, which doesn't have a MenuBar so I tested with MenuButton. Setups for both Godot 4.2 and Godot 3.5 including both MenuBar, MenuButton and PopupMenu are available at the end of this description.

Steps to reproduce

Setup:

  1. Create a blank project
  2. Add a MenuBar at top level, add a child PopupMenu (This is unique per Godot 4.2)
  3. Add a MenuButton at top level (This is for parallel comparison with Godot 3.5)
  4. Add a PopupMenu at top level (we will summon this in script)
  5. Create script to summon the popup menu on RMB

Reproduce issue:

  1. Start the game
  2. Click MenuBar or MenuButton, the popup works correctly
  3. Summon the PopupMenu by RMB on canvas area
  4. The PopupMenu shows correctly, now close it by clicking somewhere in empty space
  5. Now try to click MenuBar or MenuButton - nothing will happen
  6. (Same issue happens if instead of closing the PopupMenu by clicking somewhere else, we call hide() in script, e.g. through a key-binding; This is not shown in the video above or setup projects below)

Workaround:

  1. Switch window focus, e.g. go to other application then come back to Godot
  2. Try clicking MenuBar or MenuButton, it works again
  3. Replicate the issue, then try RMB on a MenuBar or MenuButton, which will cause TWO pops to show (one for the popup menu itself due to script summoning it, the other is for the MenuButton itself from editor/inspector setup). Close those popups, then clicking on MenuBar or MenuButton, it works.

Minimal reproduction project (MRP)

The project that shows the issue for Godot 4.2: https://github.com/Charles-Zhang-Bug-Reports/Godot_4_2_Popup_Issue
(Notably: https://github.com/Charles-Zhang-Bug-Reports/Godot_4_2_Popup_Issue/commit/b6f3360eaa06f7b0373b9bdda8e3c1fcc960be11)

The project that shows the same issue does not exist for Godot 3.5: https://github.com/Charles-Zhang-Bug-Reports/Godot_3_5_3_No_Popup_Issue (Notably: https://github.com/Charles-Zhang-Bug-Reports/Godot_3_5_3_No_Popup_Issue/commit/570fb2f2deb3976744edac32fee8d2ef03f64f33)

JtotheThree commented 7 months ago

I'm having the same issue. Left clicking away from the PopupMenu in GraphEdit hides the menu but it keeps focus. Oddly enough when it's in this broken state you can right click anywhere in the editor (outside of the GraphEdit, even the Godot main menu) and it will spawn the popup there.

chaojian-zhang commented 7 months ago

I'm having the same issue. Left clicking away from the PopupMenu in GraphEdit hides the menu but it keeps focus. Oddly enough when it's in this broken state you can right click anywhere in the editor (outside of the GraphEdit, even the Godot main menu) and it will spawn the popup there.

And calling release_focus() doesn't seem to help.

kitbdev commented 7 months ago

Can reproduce in master Godot v4.3.dev (4e990cd7e). It seems to be some embedded subwindow input propagation issue. This happens with AcceptDialogs and Popups as well as PopupMenus. The right or middle mouse button must pressed down when calling popup()/popup_centered(), it won't happen for key presses, left mouse button, or mouse up events. It works as it should when using accept_event() or turning off display/window/subwindows/embed_subwindows.

DragonMaster14545 commented 2 days ago

Yeah, I am having the exact same issue