godotengine / godotengine/godot

Menu shortcuts do not work in EditorPlugin generated windows.

Open
#110,283 2 comments 0 reactions 0 assignees View on GitHub
topic:editor topic:input topic:plugin
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in 4.4.1 official, 4.5 beta7 official

### System information

MacOS 15.6.1 (24G90)

### Issue description

Godot menus do not work when a window created by a plugin has focus. On Mac, you can see the menu item flash, as if the shortcut was doing something, but the associated menu item is not triggered. I thought this only applied to `add_tool_submenu_item` menu item shortcuts, but it appears to be almost all shortcuts.

I found this when implementing a pop-out feature for a bottom panel control. I am essentially doing the same thing as the code below. Once the control was popped out into the window, I noticed shortcuts were not working when the window had focus.

Is there a more formal way to create an "editor window", or to make a panel that pops out?

### Steps to reproduce

* Run the MRP.
* Put the focus on the editor.
* Press `ctrl+0` (zero) and it will print a message.
* Focus on the window the plugin opened.
* Press `ctrl+0` and nothing happens. On mac you can see the "Project" menu item flash.

You can also try other menu items, most don't work while the window has focus.

### Minimal reproduction project (MRP)

Here's the only code in the project.
* It makes menu item in Project->Tools-Demo Menu->Test Menu.
* The menu item has `ctrl + 0` shortcut.
* A message is printed when the menu is clicked or the shortcut triggers the menu.
* It creates a window and adds it to itself.

```gdscript
@tool
extends EditorPlugin

var sub_menu : PopupMenu = null
var window : Window = null

func _enter_tree() -> void:
sub_menu = PopupMenu.new()
add_tool_submenu_item("Demo Menu", sub_menu)
sub_menu.index_pressed.connect(_on_sub_menu_index_pressed)

sub_menu.add_item("Test Menu", 0)
sub_menu.set_item_accelerator(0, KEY_MASK_CTRL | KEY_0)

window = Window.new()
window.size = Vector2(500, 500)
window.title = "Shortcuts Don't Work Here"
add_child(window)

func _exit_tree() -> void:
sub_menu.free()
window.free()

func _on_sub_menu_index_pressed(index):
print("menu index ", index, " triggged")
```

[EditorShortcutDemo.zip](https://github.com/user-attachments/files/22177626/EditorShortcutDemo.zip)

Contributor guide

Open the contributing guide

Research direction

Start by running the attached EditorShortcutDemo.zip and reproduce ctrl+0 with focus on the editor, then on the plugin-created window. Trace how editor menu shortcuts are dispatched in each focus state; done means the shortcut triggers the menu action while the plugin window is focused, including on the reported macOS setup.

Written by the indexing model from the issue text.

Assessment

Domain
devtools, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.