-
Notifications
You must be signed in to change notification settings - Fork 63
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
Support for keyboard shortcuts in menu #75
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First of all, thank you for this library, a very handy cross-platform solution to a very common need.
What do you think about adding support for keyboard shortcuts, i.e. underlined characters in menu item texts? Currently, pystray passes the menu texts straight to the underlying backend, so that specifying
"E&xit"
produces a nice underlined x-shortcut on Windows, but on Linux the text is displayed exactly as given. On Linux, the standard shortcut character has been underscore, e.g. using"E_xit"
(except for the brave new Gnome Shell which does not support shortcut accelerators at all).So, perhaps
pystray.Menu
could have an additional methodset_accelerator(char)
, where char would specify the symbol the invoker has used in their menu texts? Then the library would replace the character in menu texts with the backend-specific accelerator symbol - or strip it altogether if the backend does not support shortcuts. And in texts where the user wants this symbol to actually be displayed, they should give it in double, e.g."Save && e&xit"
would produce"Save & exit"
with x underlined as the shortcut.It would make sense for a cross-platform library to encapsulate such platform-specific logic.
The text was updated successfully, but these errors were encountered: