KeyboardShortcuts Documentation Beta

Class Keyboard​Shortcuts.​Recorder​Cocoa

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)
	}
}
KeyboardShortcuts.RecorderCocoa KeyboardShortcuts.RecorderCocoa NSSearchField NSSearchField KeyboardShortcuts.RecorderCocoa->NSSearchField NSSearchFieldDelegate NSSearchFieldDelegate KeyboardShortcuts.RecorderCocoa->NSSearchFieldDelegate

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

minimum​Width

let minimumWidth: Double

event​Monitor

var eventMonitor: LocalEventMonitor?

shortcut​Name

let shortcutName: Name

can​Become​Key​View

var canBecomeKeyView: Bool

:nodoc:

intrinsic​Content​Size

var intrinsicContentSize: CGSize

:nodoc:

cancel​Button

var cancelButton: NSButtonCell?

shows​Cancel​Button

var showsCancelButton: Bool

Methods

control​Text​Did​Change(_:​)

public func controlTextDidChange(_ object: Notification)

:nodoc:

control​Text​Did​End​Editing(_:​)

public func controlTextDidEndEditing(_ object: Notification)

:nodoc:

become​First​Responder()

override public func becomeFirstResponder() -> Bool

:nodoc: