Keyboard shortcuts
This commit is contained in:
@@ -11,7 +11,7 @@ import UniformTypeIdentifiers
|
||||
class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegate,
|
||||
UITextFieldDelegate, ScriptPolicyViewControllerDelegate,
|
||||
UIPopoverPresentationControllerDelegate, TabDelegate, TabPickerViewControllerDelegate,
|
||||
AutocompleteViewControllerDelegate
|
||||
AutocompleteViewControllerDelegate, ShortcutResponder
|
||||
{
|
||||
let browserView = BrowserView()
|
||||
var tab: Tab { didSet { didChangeTab(tab) } }
|
||||
@@ -428,4 +428,39 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
||||
tab.beginLoadingURL(item.url)
|
||||
autocompleteViewController.view.isHidden = true
|
||||
}
|
||||
|
||||
// MARK: Keyboard shortcuts
|
||||
|
||||
func focusURLBar(_ sender: Any?) {
|
||||
toolbarController.urlBar.textField.becomeFirstResponder()
|
||||
}
|
||||
|
||||
func goBack(_ sender: Any?) {
|
||||
tab.webView.goBack()
|
||||
}
|
||||
|
||||
func goForward(_ sender: Any?) {
|
||||
tab.webView.goForward()
|
||||
}
|
||||
|
||||
func createTab(_ sender: Any?) {
|
||||
let newTab = tabController.createNewTab(url: nil)
|
||||
self.tab = newTab
|
||||
}
|
||||
|
||||
func previousTab(_ sender: Any?) {
|
||||
if let tabIndex = tabController.tabs.firstIndex(of: self.tab) {
|
||||
if tabIndex - 1 >= 0 {
|
||||
self.tab = tabController.tabs[tabIndex - 1]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func nextTab(_ sender: Any?) {
|
||||
if let tabIndex = tabController.tabs.firstIndex(of: self.tab) {
|
||||
if tabIndex + 1 < tabController.tabs.count {
|
||||
self.tab = tabController.tabs[tabIndex + 1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user