File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
Sources/KeyboardShortcuts Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,16 @@ extension KeyboardShortcuts {
24
24
}
25
25
}
26
26
```
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
+ ```
27
37
*/
28
38
public struct Recorder : NSViewRepresentable { // swiftlint:disable:this type_name
29
39
/// :nodoc:
Original file line number Diff line number Diff line change @@ -24,6 +24,16 @@ extension KeyboardShortcuts {
24
24
}
25
25
}
26
26
```
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
+ ```
27
37
*/
28
38
public final class RecorderCocoa : NSSearchField , NSSearchFieldDelegate {
29
39
private let minimumWidth : Double = 130
@@ -224,9 +234,7 @@ extension KeyboardShortcuts {
224
234
userDefaultsRemove ( name: shortcutName)
225
235
}
226
236
227
- if let onChange = self . onChange {
228
- onChange ( shortcut)
229
- }
237
+ onChange ? ( shortcut)
230
238
}
231
239
}
232
240
}
You can’t perform that action at this time.
0 commit comments