How do I design my software for remappable short-cut keys? [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and开发者_StackOverflow more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this questionI've just started on a GUI application which will feature several distinct modes and a large number of keyboard shortcuts. Ideally I'd like to support letting the user remap these, like in eclipse. What is - if any - the standard solution to this situation? I can imagine the main window captures all key-presses and translate them to key-neutral events for all the child controls as one way, but it feels clumsy. Are there any standard frameworks for doing this? If so, particularly python or open-sourced ones that I could use as an example are of interest.
I might use something like the Command Pattern. Create a hashtable, where the key is the key pressed, and the value is a function (or object with a function) that's the action to be executed.
While there's probably a much faster way to do this in CPU-time, that seems the cleanest and most maintainable way, and it's fast enough for a single-user application that clean code should be pretty important.
精彩评论