发布于 2017-12-11 21:55:16
发布于 2020-12-20 15:38:38
我做了一个Swift软件包,它让这件事变得很简单:
import KeyboardShortcuts
extension KeyboardShortcuts.Name {
static let startFiveRounds = Self("startFiveRounds", default: .init(.t, modifiers: [.command, .option]))
}
@main
final class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ notification: Notification) {
KeyboardShortcuts.onKeyUp(for: .startFiveRounds) {
// …
}
}
}即使你已经解决了你的问题,我认为这对其他有同样问题的人是有用的。
我还建议让用户选择自己的键盘快捷方式,而不是硬编码。我的包附带了一个控件,用户可以在其中设置他们喜欢的快捷方式。
https://stackoverflow.com/questions/47760135
复制相似问题