Double-click command to present a shortcut guide for your macOS application.
Add these lines to your root window's NSWindowController
:
import ShortcutGuide
// ...
override func windowDidLoad() {
super.windowDidLoad()
// ...
ShortcutGuideWindowController.registerShortcutGuideForWindow(window!)
}
Then, make some parts of your responder chain (NSView
or NSViewController
) conform to ShortcutGuideDataSource
:
public protocol ShortcutGuideDataSource: NSResponder {
var shortcutItems: [ShortcutItem] { get }
}
Define and provide your shortcuts from the protocol method above:
public struct ShortcutItem {
let name: String
let keyString: String
let toolTip: String
let modifierFlags: NSEvent.ModifierFlags
}
Copyright © 2021 Zheng Wu. All rights reserved.