From 55ab759bf7007d22661cc4162a1659cce2dc9c64 Mon Sep 17 00:00:00 2001 From: James Magahern Date: Mon, 21 Sep 2020 18:40:23 -0700 Subject: [PATCH] Keyboard shortcuts: Support for iPad too --- App/AppDelegate.swift | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/App/AppDelegate.swift b/App/AppDelegate.swift index 6971543..0a8ff5d 100644 --- a/App/AppDelegate.swift +++ b/App/AppDelegate.swift @@ -22,8 +22,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) } - override func buildMenu(with builder: UIMenuBuilder) { - let fileCommands = [ + static func fileMenuShortcuts() -> [UIKeyCommand] { + [ // Open Location... UIKeyCommand( modifiers: .command, input: "L", @@ -66,9 +66,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate { action: #selector(ShortcutResponder.nextTab) ), ] - + } + + override var keyCommands: [UIKeyCommand]? { + get { return Self.fileMenuShortcuts() } + } + + override func buildMenu(with builder: UIMenuBuilder) { builder.replaceChildren(ofMenu: .file) { children in - return fileCommands + children + return Self.fileMenuShortcuts() + children } } }