Implements zoom in/out keyboard shortcuts

This commit is contained in:
James Magahern
2024-10-17 13:38:41 -07:00
parent 0fd466d86d
commit 177db26b69
2 changed files with 35 additions and 0 deletions

View File

@@ -144,6 +144,10 @@ extension BrowserViewController: ShortcutResponder
webView.reload()
}
func stop(_ sender: Any?) {
webView.stopLoading()
}
override func increaseSize(_ sender: Any?) {
currentTab.webView._viewScale += 0.10
}
@@ -151,6 +155,10 @@ extension BrowserViewController: ShortcutResponder
override func decreaseSize(_ sender: Any?) {
currentTab.webView._viewScale -= 0.10
}
func zoomToActualSize(_ sender: Any?) {
currentTab.webView._viewScale = 1.0
}
func showPreferences(_ sender: Any?) {
showSettingsWindow()

View File

@@ -63,6 +63,9 @@ protocol ShortcutResponder: AnyObject {
@objc
optional func raiseScriptPolicyRestriction(_ sender: Any?)
@objc
optional func zoomToActualSize(_ sender: Any?)
}
public class OpenURLEvent: UIEvent {
@@ -224,6 +227,30 @@ public class KeyboardShortcuts {
case .view:
return [
// Zoom
UIMenu(options: .displayInline, children: [
// Actual Size
UIKeyCommand(
modifiers: .command, input: "0",
title: "Actual Size",
action: #selector(ShortcutResponder.zoomToActualSize)
),
// Increase Zoom
UIKeyCommand(
modifiers: .command, input: "=",
title: "Zoom In",
action: #selector(UIResponder.increaseSize)
),
// Go Forward
UIKeyCommand(
modifiers: .command, input: "-",
title: "Zoom Out",
action: #selector(UIResponder.decreaseSize)
),
]),
// Toggle Dark Mode
UIKeyCommand(
modifiers: [.command], input: "M",