Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MenuItems should display their HotKeys #340

Open
yshklarov opened this issue Feb 6, 2024 · 6 comments
Open

MenuItems should display their HotKeys #340

yshklarov opened this issue Feb 6, 2024 · 6 comments

Comments

@yshklarov
Copy link

yshklarov commented Feb 6, 2024

The problem

Menus in Windows applications typically display their associated hotkeys, right-aligned, as part of the menu's header. Otherwise, the HotKey is not discoverable, which makes the HotKey useless in practice in many cases.

Request

It should be possible (in fact, it should be the default) for a MenuItem to display its HotKey to the right of the Header.

Workaround

For now, the HotKey can be manually added in parentheses at the end of the Header. However, this is ugly because it's not right-aligned (and tab stops don't work here).

Example

Here's the main menu in Firefox. The hotkeys can be seen to the right of each menu header.
image

@rabbitism
Copy link
Collaborator

rabbitism commented Feb 6, 2024

Avalonia already supports this. You can assign InputGesture for each MenuItem.
Attached is my own theme but Fluent/Simple theme should also support this.
image

@yshklarov
Copy link
Author

Oh, excellent, thank you!

May I suggest that the MenuItem's InputGesture and HotKey properties' API reference pages link to each other to make this more clear?

@thevortexcloud
Copy link
Contributor

thevortexcloud commented Feb 6, 2024

There is also a convention way of doing this. Which is to put a _ at the start of the header text. EG _File will make the hot key set to F as that's the first letter in the string. The _ will be automatically removed. It will show up if you press ALT with the menu focused. It's fairly useful if you have a simple menu.

https://docs.avaloniaui.net/docs/reference/controls/menu

@yshklarov
Copy link
Author

yshklarov commented Feb 6, 2024

There is also a convention way of doing this. Which is to put a _ at the start of the header text. EG _File will make the hot key set to F as that's the first letter in the string. The _ will be automatically removed. It will show up if you press ALT with the menu focused. It's fairly useful if you have a simple menu.

https://docs.avaloniaui.net/docs/reference/controls/menu

This is useful, too, but it's not quite the same thing. A HotKey can be used without pressing Alt and bringing the menu open. A HotKey is something like Ctrl-S to save the current document, which is distinct from the "accelerator" Alt-F → S that performs the same command. Many menu commands need to have both.

@thevortexcloud
Copy link
Contributor

Ah right, I misread your post. My bad.

@timunie
Copy link
Contributor

timunie commented Feb 6, 2024

@yshklarov sounds like it's a docs issue then. So I'll move it there.

@timunie timunie transferred this issue from AvaloniaUI/Avalonia Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants