https://github.com/louisdh/keycommandalertcontroller
UIAlertController wrapper to add keyboard shortcuts easily
https://github.com/louisdh/keycommandalertcontroller
ios ipad keyboard ui uialertcontroller uikit ux
Last synced: about 11 hours ago
JSON representation
UIAlertController wrapper to add keyboard shortcuts easily
- Host: GitHub
- URL: https://github.com/louisdh/keycommandalertcontroller
- Owner: louisdh
- Created: 2017-03-18T22:34:33.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-19T19:20:59.000Z (about 8 years ago)
- Last Synced: 2025-04-18T10:24:02.883Z (6 days ago)
- Topics: ios, ipad, keyboard, ui, uialertcontroller, uikit, ux
- Language: Swift
- Size: 761 KB
- Stars: 19
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# KeyCommandAlertController
This project contains wrappers for ```UIAlertController``` and ```UIAlertAction``` to easily add keyboard shortcuts (known as ```key command```).
The following example shows how the action sheet shown above is created:
```swift
let alert = KeyCommandAlertController(title: "Change background color", message: nil, preferredStyle: .actionSheet)alert.popoverPresentationController?.barButtonItem = sender
let redShortcut = KeyCommandShortcut(input: "B", modifierFlags: .command)
let redAction = KeyCommandAlertAction(title: "Blue", style: .default, keyShortcut: redShortcut) { (action) in
self.makeBlue()
}let greenShortcut = KeyCommandShortcut(input: "R", modifierFlags: .command)
let greenAction = KeyCommandAlertAction(title: "Red", style: .default, keyShortcut: greenShortcut) { (action) in
self.makeRed()
}let cancelAction = KeyCommandAlertAction(title: "Cancel", style: .cancel)
alert.addAction(redAction)
alert.addAction(greenAction)
alert.addAction(cancelAction)present(alert, animated: true, completion: nil)
```### TODO
- [ ] Only show shortcuts in alert actions when external keyboard is connected