Keyboard shortcuts

This commit is contained in:
James Magahern
2020-09-21 18:35:39 -07:00
parent 14a28a0776
commit e934a4d3f5
5 changed files with 138 additions and 1 deletions

View File

@@ -21,5 +21,55 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
{
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
override func buildMenu(with builder: UIMenuBuilder) {
let fileCommands = [
// Open Location...
UIKeyCommand(
modifiers: .command, input: "L",
title: "Open Location",
action: #selector(ShortcutResponder.focusURLBar)
),
// Go Back
UIKeyCommand(
modifiers: .command, input: "[",
title: "Go Back",
action: #selector(ShortcutResponder.goBack)
),
// Go Forward
UIKeyCommand(
modifiers: .command, input: "]",
title: "Go Forward",
action: #selector(ShortcutResponder.goForward)
),
// Create Tab
UIKeyCommand(
modifiers: .command, input: "T",
title: "New Tab",
action: #selector(ShortcutResponder.createTab)
),
// Previous Tab
UIKeyCommand(
modifiers: [.command, .shift], input: "[",
title: "Previous Tab",
action: #selector(ShortcutResponder.previousTab)
),
// Next Tab
UIKeyCommand(
modifiers: [.command, .shift], input: "]",
title: "Next Tab",
action: #selector(ShortcutResponder.nextTab)
),
]
builder.replaceChildren(ofMenu: .file) { children in
return fileCommands + children
}
}
}