Skip to content

Commit

Permalink
Add iPad keyboard shortcuts (mozilla-mobile#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyg authored and boek committed Sep 27, 2017
1 parent 835b3e2 commit 38cd519
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Blockzilla/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,31 @@ class BrowserViewController: UIViewController {
alertController.popoverPresentationController?.sourceRect = CGRect(x: self.view.bounds.size.width / 2.0, y: self.view.bounds.size.height / 2.0, width: 1.0, height: 1.0)
present(alertController, animated: true, completion: nil)
}

@objc private func selectLocationBar() {
urlBar.becomeFirstResponder()
}

@objc private func reload() {
browser.reload()
}

@objc private func goBack() {
browser.goBack()
}

@objc private func goForward() {
browser.goForward()
}

override var keyCommands: [UIKeyCommand]? {
return [
UIKeyCommand(input: "l", modifierFlags: .command, action: #selector(BrowserViewController.selectLocationBar), discoverabilityTitle: UIConstants.strings.selectLocationBarTitle),
UIKeyCommand(input: "r", modifierFlags: .command, action: #selector(BrowserViewController.reload), discoverabilityTitle: UIConstants.strings.browserReload),
UIKeyCommand(input: "[", modifierFlags: .command, action: #selector(BrowserViewController.goBack), discoverabilityTitle: UIConstants.strings.browserBack),
UIKeyCommand(input: "]", modifierFlags: .command, action: #selector(BrowserViewController.goForward), discoverabilityTitle: UIConstants.strings.browserForward),
]
}
}

extension BrowserViewController: URLBarDelegate {
Expand Down
1 change: 1 addition & 0 deletions Blockzilla/UIConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,6 @@ struct UIConstants {
static let analyticTrackerLabel = NSLocalizedString("trackingProtection.analyticTrackerLabel", value: "Analytic trackers", comment: "label for analytic trackers.")
static let socialTrackerLabel = NSLocalizedString("trackingProtection.socialTrackerLabel", value: "Social trackers", comment: "label for social trackers.")
static let contentTrackerLabel = NSLocalizedString("trackingProtection.contentTrackerLabel", value: "Content trackers", comment: "label for content trackers.")
static let selectLocationBarTitle = NSLocalizedString("browserShortcutDescription.selectLocationBar", value: "Select Location Bar", comment: "Label to display in the Discoverability overlay for keyboard shortcuts")
}
}

0 comments on commit 38cd519

Please sign in to comment.