sindresorhus/KeyboardShortcuts

Request for minimal working example with Storyboard

nguyenvukhang opened this issue · 1 comments

After trying all sorts of minimal working examples (and failing) just to get one RecorderCocoa to show up, can I humbly request for a simple "helloworld" level MWE with these settings?

Screenshot 2024-05-25 at 15 33 24

What I've tried so far is to

  1. Initialize the project as shown above
  2. Set the ViewController.swift file to
import Cocoa
import KeyboardShortcuts

extension KeyboardShortcuts.Name {
    static let toggleUnicornMode = Self("toggleUnicornMode")
}

class ViewController: NSViewController {
    @IBOutlet var button: NSView!
    let recorder = KeyboardShortcuts.RecorderCocoa(for: .toggleUnicornMode)

    override func viewDidLoad() {
        super.viewDidLoad()
        button.addSubview(recorder)
    }
}

But nothing shows up. Any help is appreciated. Thanks.

Turns out, adding

recorder.frame = CGRect(x: 0, y: 0, width: 100, height: 25)

before button.addSubview(recorder) is one way to get it to work.