Class
KeyboardShortcuts.RecorderCocoa
public final class RecorderCocoa: NSSearchField, NSSearchFieldDelegate
A NSView
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 Cocoa
import KeyboardShortcuts
final class PreferencesViewController: NSViewController {
override func loadView() {
view = NSView()
let recorder = KeyboardShortcuts.RecorderCocoa(for: .toggleUnicornMode)
view.addSubview(recorder)
}
}
Relationships
Member Of
KeyboardShortcuts
Global keyboard shortcuts for your macOS app.
Conforms To
NSSearchField
NSSearchFieldDelegate
Initializers
init(for:)
public required init(for name: Name)
init?(coder:)
@available(*, unavailable) public required init?(coder: NSCoder)
Properties
minimumWidth
let minimumWidth: Double
eventMonitor
var eventMonitor: LocalEventMonitor?
shortcutName
let shortcutName: Name
canBecomeKeyView
var canBecomeKeyView: Bool
:nodoc:
intrinsicContentSize
var intrinsicContentSize: CGSize
:nodoc:
cancelButton
var cancelButton: NSButtonCell?
showsCancelButton
var showsCancelButton: Bool
Methods
controlTextDidChange(_:)
public func controlTextDidChange(_ object: Notification)
:nodoc:
controlTextDidEndEditing(_:)
public func controlTextDidEndEditing(_ object: Notification)
:nodoc:
becomeFirstResponder()
override public func becomeFirstResponder() -> Bool
:nodoc: