Shortcuts: close tab keyboard shortcut
This commit is contained in:
@@ -59,6 +59,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||||||
action: #selector(ShortcutResponder.previousTab)
|
action: #selector(ShortcutResponder.previousTab)
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Close tab
|
||||||
|
UIKeyCommand(
|
||||||
|
modifiers: [.command], input: "W",
|
||||||
|
title: "Close Tab",
|
||||||
|
action: #selector(ShortcutResponder.closeTab)
|
||||||
|
),
|
||||||
|
|
||||||
// Next Tab
|
// Next Tab
|
||||||
UIKeyCommand(
|
UIKeyCommand(
|
||||||
modifiers: [.command, .shift], input: "]",
|
modifiers: [.command, .shift], input: "]",
|
||||||
|
|||||||
@@ -597,6 +597,20 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func closeTab(_ sender: Any?) {
|
||||||
|
if tabController.tabs.count > 1 {
|
||||||
|
tabController.closeTab(self.tab)
|
||||||
|
} else {
|
||||||
|
#if targetEnvironment(macCatalyst)
|
||||||
|
if let originWindowScene = self.view.window?.windowScene {
|
||||||
|
UIApplication.shared.requestSceneSessionDestruction(originWindowScene.session, options: nil) { error in
|
||||||
|
print("Error when requesting scene destruction: " + error.localizedDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func findOnPage(_ sender: Any?) {
|
func findOnPage(_ sender: Any?) {
|
||||||
browserView.setFindOnPageVisible(true, animated: true)
|
browserView.setFindOnPageVisible(true, animated: true)
|
||||||
findOnPageController.findOnPageView.textField.becomeFirstResponder()
|
findOnPageController.findOnPageView.textField.becomeFirstResponder()
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ protocol ShortcutResponder: class {
|
|||||||
@objc
|
@objc
|
||||||
optional func nextTab(_ sender: Any?)
|
optional func nextTab(_ sender: Any?)
|
||||||
|
|
||||||
|
@objc
|
||||||
|
optional func closeTab(_ sender: Any?)
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
optional func findOnPage(_ sender: Any?)
|
optional func findOnPage(_ sender: Any?)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user