Skip to content

Commit 00222ac

Browse files
committed
document the initializers
1 parent ef5c34e commit 00222ac

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

Sources/KeyboardShortcuts/Recorder.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@ extension KeyboardShortcuts {
2424
}
2525
}
2626
```
27-
28-
An optional onChange callback can be set on the Recorder which will be called when the shortcut is sucessfully changed/removed.
29-
30-
This could be useful if you would like to store the keyboard shortcut somewhere yourself instead of rely on the build-in `UserDefaults` storage.
31-
32-
```
33-
KeyboardShortcuts.Recorder(for: .toggleUnicornMode, onChange: { (shortcut: KeyboardShortcuts.Shortcut?) in
34-
print("Changed shortcut to:", shortcut)
35-
})
36-
```
3727
*/
3828
public struct Recorder: NSViewRepresentable { // swiftlint:disable:this type_name
3929
/// :nodoc:
@@ -42,6 +32,16 @@ extension KeyboardShortcuts {
4232
private let name: Name
4333
private let onChange: ((_ shortcut: Shortcut?) -> Void)?
4434

35+
/**
36+
Creates a new Recorder view
37+
- Parameter name: strongly typed `KeyboardShortcuts.Name`
38+
- Parameter onChange: optional callback which will be called when the shortcut is successfully changed/removed. This could be useful if you would like to store the keyboard shortcut somewhere yourself instead of rely on the build-in `UserDefaults` storage.
39+
```
40+
KeyboardShortcuts.Recorder(for: .toggleUnicornMode, onChange: { (shortcut: KeyboardShortcuts.Shortcut?) in
41+
print("Changed shortcut to:", shortcut)
42+
})
43+
```
44+
**/
4545
public init(for name: Name, onChange: ((_ shortcut: Shortcut?) -> Void)? = nil) {
4646
self.name = name
4747
self.onChange = onChange

Sources/KeyboardShortcuts/RecorderCocoa.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@ extension KeyboardShortcuts {
2424
}
2525
}
2626
```
27-
28-
An optional onChange callback can be set on the Recorder which will be called when the shortcut is sucessfully changed/removed.
29-
30-
This could be useful if you would like to store the keyboard shortcut somewhere yourself instead of rely on the build-in `UserDefaults` storage.
31-
32-
```
33-
KeyboardShortcuts.RecorderCocoa(for: .toggleUnicornMode, onChange: { (shortcut: KeyboardShortcuts.Shortcut?) in
34-
print("Changed shortcut to:", shortcut)
35-
})
36-
```
3727
*/
3828
public final class RecorderCocoa: NSSearchField, NSSearchFieldDelegate {
3929
private let minimumWidth: Double = 130
@@ -60,6 +50,16 @@ extension KeyboardShortcuts {
6050
}
6151
}
6252

53+
/**
54+
Creates a new RecorderCocoa view
55+
- Parameter name: strongly typed `KeyboardShortcuts.Name`
56+
- Parameter onChange: optional callback which will be called when the shortcut is successfully changed/removed. This could be useful if you would like to store the keyboard shortcut somewhere yourself instead of rely on the build-in `UserDefaults` storage.
57+
```
58+
KeyboardShortcuts.RecorderCocoa(for: .toggleUnicornMode, onChange: { (shortcut: KeyboardShortcuts.Shortcut?) in
59+
print("Changed shortcut to:", shortcut)
60+
})
61+
```
62+
**/
6363
public required init(for name: Name, onChange: ((_ shortcut: Shortcut?) -> Void)? = nil) {
6464
self.shortcutName = name
6565
self.onChange = onChange

0 commit comments

Comments
 (0)