Long press on the window button to open a new tab

This commit is contained in:
James Magahern
2020-07-31 16:36:10 -07:00
parent 5457a05309
commit 030c1db45c
4 changed files with 41 additions and 0 deletions

View File

@@ -123,6 +123,22 @@ class BrowserViewController: UIViewController, WKNavigationDelegate,
self.present(navController, animated: true, completion: nil)
}), for: .touchUpInside)
let newTabAction = UIAction { [unowned self] action in
if let gestureRecognizer = action.sender as? UILongPressGestureRecognizer {
if gestureRecognizer.state != .began { return }
}
// Create new tab
let newTab = tabController.createNewTab(url: nil)
self.tab = newTab
}
let gestureRecognizer = UILongPressGestureRecognizer(action: newTabAction)
toolbarController.windowButton.addGestureRecognizer(gestureRecognizer)
// New tab button
toolbarController.newTabButton.addAction(newTabAction, for: .touchUpInside)
// TextField delegate
toolbarController.urlBar.textField.delegate = self