开发者

How do I design my software for remappable short-cut keys? [closed]

开发者 https://www.devze.com 2023-01-11 18:27 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

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 question

I'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.

0

精彩评论

暂无评论...
验证码 换一张
取 消