-
-
Notifications
You must be signed in to change notification settings - Fork 689
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
Multiple shortcut keys for a single command #731
Comments
Glad to hear Podium worked for you! Not sure I understand the feature request, though. What is the significance of your editors bindings? Are shortcut collections a feature of GTK/Linux/Ubuntu that I'm not aware of? Or are you suggesting that we allow multiple shortcuts for a single Command? In which case - how would we determine which shortcut was currently "active"? |
To accommodate those of us who've melded our brains with our editor, many popular tools provide support for the bindings of Vim and/or Emacs in addition to the more "modern" bindings.
There is
Exactly. For example, I would like
I'm thinking it needn't be just one; pressing any of |
Sorry about the confusion, re-reading my message I can see why it's not clear. By " toga.Command(
self.next_slide,
label='Next slide',
shortcut=toga.Key.RIGHT,
), it could be toga.Command(
self.next_slide,
label='Next slide',
shortcuts={toga.Key.RIGHT, toga.KEY.j},
), |
Ok; I think I've got a better understanding now. I'm not sure what you're asking for is strictly possible - at least, not at the Toga level. Most operating systems only allow a single keybinding to a menu command (that's definintely true of macOS and Windows). Can you give an example of a GUI application that has multiple keybindings for a single command? In the specific case of Podium, it might be possible - but only because the slide deck has an additional layer of control that is independent of the command definition. For example, although the menu lists left/right arrow as the binding for next/previous, up/down are also bound to the same action at the level of the slide deck. I'm a little wary of adding dozens of key bindings for forward/backward - but that's a feature request that can be discussed on the Podium issue tracker. |
I realize most of these are not the targets that Toga supports. If some/most/all GUI systems don't support it natively, I still think it's a useful enough feature that it'd be worth providing a workaround so that other keys would work, even if they're not displayed in the GUI menu. For example, Command(shortcut=toga.Key.RIGHT, shortcut_aliases=[toga.KEY('l')]) If that's not possible, or possibly as a separate feature, it'd be nice to have an interface for switching between "basic bindings", "emacs bindings", and "vim bindings". RStudio (a Qt app) has a setting for that, for example. |
For clarity - there's a difference between "has multiple keyboard shortcuts" and "has multiple keyboard shortcuts displayed in the menu". In the Browser example, for example, you'll only see one shortcut (usually CMD R) displayed as a hint; the other Just Works. To that end - the "alias" approach you've described seems reasonable; menus will use the shortcut, and alias bindings will be added as allowed on each platforms. We may also want to consider allowing making Shortcut a dictionary, so you can make shortcuts that are platform specific. For example, in Podium, MOD1-Tab is the current command for switch screens, which is CMD-Tab on macOS; but Ctrl-TAB is reserved by the OS (AFAICT) on Linux. Collisions with existing or system key bindings are likely to be common, so we should accomodate them, and any system-wide alias tooling that exists (like dconf-editor). The separate feature of "use X bindings" is also a nice idea; it's more of a feature that would be specific to Podium in this case, although Toga would need to provide the infrastructure to make it possible - specifically, an implementation of #90. |
I just tried Podium in Python3.7 on Ubuntu 18.04, it worked great.
There was no support for my editor's bindings though, which I think is because
toga.command.Command
only has oneshortcut
attribute. I propose changing it to ashortcuts
collection. It could retain theshortcut
api for backward compatibility.The text was updated successfully, but these errors were encountered: