godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Allow using digits as accelerator keys in popup menus #10470

Open passivestar opened 1 month ago

passivestar commented 1 month ago

Describe the project you are working on

Any project

Describe the problem or limitation you are having in your project

Clicking buttons with the mouse is slow. Coming up with unique hotkeys for every action is cumbersome and not always possible as not everything is exposed to hotkeys

Describe the feature / enhancement and how it helps to overcome the problem or limitation

When a PopupMenu is opened you can press digits on the keyboard to immediately activate items in it. It works with submenus too, allowing you to chain digit combinations to quickly reach any nested menu item.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Comparison for "Create Script":

https://github.com/user-attachments/assets/6938b1db-de6c-4c32-b65f-83fa65648239

Works for any buttons. Holding Shift allows you to reach items in 10-20 index range, like in Blender

https://github.com/user-attachments/assets/a969d51e-0466-40cf-802c-82c0ec78d32a

RMB+4 to create a cube mesh:

https://github.com/user-attachments/assets/f03c6aef-499d-4abe-8a58-f78e47399af0

Note: Blender also underlines unique letters in popup menus allowing you to press those to activate menu items in a similar fashion. Since Godot already does "search" when letters are pressed I'm only proposing to use digits for now. However I'm open to possibility of changing the behavior of pressing letters in the future as well to make this feature more powerful

Note 2: I made a Blender addon that leverages this functionality to the fullest, it has proven to be efficient to a lot of people

If this enhancement will not be used often, can it be worked around with a few lines of script?

No

Is there a reason why this should be core and not an add-on in the asset library?

Modifying the behaviour of editor popup menus from an addon is hacky, godot doesn't have editor:// addons yet, and this is a useful power feature

Nodragem commented 1 month ago

that's such a brilliant idea!

I'm just not a big fan of using SHIFT for 10-20, really straining on the pinky. Could we use SHIFT as a sticky key to avoid the strain?

Also we could use the key just on the left of 1 (the symbol ` on British keyboard) instead of SHIFT? just random thoughts :)

passivestar commented 1 month ago

Could we use SHIFT as a sticky key to avoid the strain?

Hmm, I guess we could try that

Also we could use the key just on the left of 1

No precedent for that in any software but we could try that too I guess, see how it feels. I'm not a big fan of shift either

Calinou commented 1 month ago

Is this standard OS behavior on any platform? If not, I fear it'll be difficult to discover unless it's a well-known trick by Blender users.

Accelearators do exist as a standard OS behavior, but they require holding Alt and pressing an underlined letter (the underline generally only appears when pressing Alt).

passivestar commented 1 month ago

The current search feature where it selects items when you type is hard to discover too. But perhaps if we convert it into a bit more conventional accelerator behavior (with always-underlined letters) it would both:

  1. Make it more obvious that pressing letters does something
  2. Make it less of a stretch to imagine that pressing numbers does something too (despite no visual indication)

I think since this is more of a power-user feature it's alright that it's not immediately discoverable. On Windows there's no way to know that accelerator keys exist, you can only stumble into them accidentally by pressing Alt. It's probably fine to leave some advanced features to tutorials and let people learn them in time when they decide to hyper-optimize their workflows

Nodragem commented 1 month ago

Discoverability is indeed important, but power user features should first be thought based on efficiency? then they are many ways to make them known/visible.

If it really needs to be explicit, we could show numbers in gray on the left-hand side; it would also help the user (who would need to mentally count otherwise). But maybe, a user preference should allow to disable the numbering? Here an example: mock-up-power-menu

Also, I think it could be even more efficient if we can "right-click" by pressing the key `. Then if ` is pressed again it jumps to 10, if pressed again, jump to 20. The space key could also be a good candidate to open context menu and jump to next multiple of 10.

For the search feature, I didn't know, and I still don't see what you mean 😄

What seems to work at the moment is to press the first letter of an items. Beloew I right-clicked and I pressed N a few times, then I pressed C to go to "Clear" but it doesn't work. I needed to right-click again and do C to get to "Clear". right-click-menu

Calinou commented 1 month ago

For the search feature, I didn't know, and I still don't see what you mean 😄

@passivestar is likely referring to ItemList and Tree where you can input the first letters of an entry and it'll focus the entry automatically. This is standard OS behavior, especially in file managers, and Godot replicates it more or less.

This behavior also seems to work in PopupMenu, and seems to be OS behavior on Linux (with KDE) at least. It doesn't require clicking the popup to work there though, so the fact that you need to click the popup first is likely a bug. Does this still occur with Single Window Mode enabled in the Editor Settings?