parent
ab6822ade2
commit
9bc72c441c
|
@ -20,6 +20,11 @@ extension KeyboardShortcuts {
|
|||
public let rawValue: String
|
||||
public let defaultShortcut: Shortcut?
|
||||
|
||||
/**
|
||||
Get the keyboard shortcut assigned to the name.
|
||||
*/
|
||||
public var shortcut: Shortcut? { KeyboardShortcuts.getShortcut(for: self) }
|
||||
|
||||
/**
|
||||
- Parameter name: Name of the shortcut.
|
||||
- Parameter default: Optional default key combination. Do not set this unless it's essential. Users find it annoying when random apps steal their existing keyboard shortcuts. It's generally better to show a welcome screen on the first app launch that lets the user set the shortcut.
|
||||
|
|
30
readme.md
30
readme.md
|
@ -181,6 +181,36 @@ extension KeyboardShortcuts.Name {
|
|||
}
|
||||
```
|
||||
|
||||
#### Get all keyboard shortcuts
|
||||
|
||||
To get all the keyboard shortcut `Name`'s, conform `KeyboardShortcuts.Name` to `CaseIterable`.
|
||||
|
||||
```swift
|
||||
import KeyboardShortcuts
|
||||
|
||||
extension KeyboardShortcuts.Name {
|
||||
static let foo = Self("foo")
|
||||
static let bar = Self("bar")
|
||||
}
|
||||
|
||||
extension KeyboardShortcuts.Name: CaseIterable {
|
||||
public static let allCases: [Self] = [
|
||||
.foo,
|
||||
.bar
|
||||
]
|
||||
}
|
||||
|
||||
// …
|
||||
|
||||
print(KeyboardShortcuts.Name.allCases)
|
||||
```
|
||||
|
||||
And to get all the `Name`'s with a set keyboard shortcut:
|
||||
|
||||
```swift
|
||||
print(KeyboardShortcuts.Name.allCases.filter { $0.shortcut != nil })
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
||||
#### How is it different from [`MASShortcut`](https://github.com/shpakovski/MASShortcut)?
|
||||
|
|
Loading…
Reference in New Issue