Long press on the window button to open a new tab
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user