Fix Cmd+N shortcut for Compose not working on Mac (Catalyst or Designed

for iPad)
This commit is contained in:
Shadowfacts 2022-05-15 10:34:24 -04:00
parent ecab33bdce
commit b46f007f64
2 changed files with 11 additions and 4 deletions

View File

@ -67,7 +67,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
override func buildMenu(with builder: UIMenuBuilder) {
super.buildMenu(with: builder)
if builder.system == .main {
MenuController.buildMainMenu(builder: builder)
@ -107,4 +106,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return "compose"
}
}
@objc func closeWindow() {
guard let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) else {
return
}
UIApplication.shared.requestSceneSessionDestruction(scene.session, options: nil)
}
}

View File

@ -52,20 +52,21 @@ struct MenuController {
static let prevSubTabCommand = UIKeyCommand(title: "Previous Sub Tab", action: #selector(TabbedPageViewController.selectPrevPage), input: "[", modifierFlags: [.command, .shift])
static func buildMainMenu(builder: UIMenuBuilder) {
builder.insertChild(buildFileMenu(), atStartOfMenu: .file)
builder.replace(menu: .file, with: buildFileMenu())
builder.insertChild(buildSubTabMenu(), atStartOfMenu: .view)
builder.insertChild(buildSidebarShortcuts(), atStartOfMenu: .view)
}
private static func buildFileMenu() -> UIMenu {
return UIMenu(
title: "",
title: "File",
image: nil,
identifier: nil,
options: .displayInline,
options: [],
children: [
composeCommand,
refreshCommand(discoverabilityTitle: nil),
UIKeyCommand(title: "Close", action: #selector(AppDelegate.closeWindow), input: "w", modifierFlags: .command),
]
)
}