iPad trackpad and key shortcuts improvements

This commit is contained in:
Ilya Laktyushin
2022-07-30 03:51:46 +03:00
parent 6c4a730b42
commit 5b8961d02a
46 changed files with 1035 additions and 83 deletions

View File

@@ -71,7 +71,7 @@ public final class AlertControllerTheme: Equatable {
}
}
open class AlertController: ViewController, StandalonePresentableController {
open class AlertController: ViewController, StandalonePresentableController, KeyShortcutResponder {
private var controllerNode: AlertControllerNode {
return self.displayNode as! AlertControllerNode
}
@@ -155,4 +155,44 @@ open class AlertController: ViewController, StandalonePresentableController {
self?.dismiss()
}
}
public var keyShortcuts: [KeyShortcut] {
return [
KeyShortcut(
input: UIKeyCommand.inputEscape,
modifiers: [],
action: { [weak self] in
self?.dismissAnimated()
}
),
KeyShortcut(
input: "W",
modifiers: [.command],
action: { [weak self] in
self?.dismissAnimated()
}
),
KeyShortcut(
input: "\r",
modifiers: [],
action: { [weak self] in
self?.controllerNode.performHighlightedAction()
}
),
KeyShortcut(
input: UIKeyCommand.inputUpArrow,
modifiers: [],
action: { [weak self] in
self?.controllerNode.decreaseHighlightedIndex()
}
),
KeyShortcut(
input: UIKeyCommand.inputDownArrow,
modifiers: [],
action: { [weak self] in
self?.controllerNode.increaseHighlightedIndex()
}
)
]
}
}