Structure
KeyboardShortcuts.Recorder
public struct Recorder: NSViewRepresentable
A SwiftUI View
that lets the user record a keyboard shortcut.
You would usually put this in your preferences window.
It automatically prevents choosing a keyboard shortcut that is already taken by the system or by the app's main menu by showing a user-friendly alert to the user.
It takes care of storing the keyboard shortcut in UserDefaults
for you.
import SwiftUI
import KeyboardShortcuts
struct PreferencesView: View {
var body: some View {
HStack {
Text("Toggle Unicorn Mode:")
KeyboardShortcuts.Recorder(for: .toggleUnicornMode)
}
}
}
Relationships
Member Of
KeyboardShortcuts
Global keyboard shortcuts for your macOS app.
Conforms To
NSViewRepresentable
Nested Type Aliases
NSViewType
public typealias NSViewType = RecorderCocoa
:nodoc:
Initializers
init(for:)
public init(for name: Name)
Properties
name
let name: Name
Methods
makeNSView(context:)
public func makeNSView(context: Context) -> NSViewType
:nodoc:
updateNSView(_:context:)
public func updateNSView(_ nsView: NSViewType, context: Context)
:nodoc: