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() webView.reload()
} }
func stop(_ sender: Any?) {
webView.stopLoading()
}
override func increaseSize(_ sender: Any?) { override func increaseSize(_ sender: Any?) {
currentTab.webView._viewScale += 0.10 currentTab.webView._viewScale += 0.10
} }
@@ -152,6 +156,10 @@ extension BrowserViewController: ShortcutResponder
currentTab.webView._viewScale -= 0.10 currentTab.webView._viewScale -= 0.10
} }
func zoomToActualSize(_ sender: Any?) {
currentTab.webView._viewScale = 1.0
}
func showPreferences(_ sender: Any?) { func showPreferences(_ sender: Any?) {
showSettingsWindow() showSettingsWindow()
} }

View File

@@ -63,6 +63,9 @@ protocol ShortcutResponder: AnyObject {
@objc @objc
optional func raiseScriptPolicyRestriction(_ sender: Any?) optional func raiseScriptPolicyRestriction(_ sender: Any?)
@objc
optional func zoomToActualSize(_ sender: Any?)
} }
public class OpenURLEvent: UIEvent { public class OpenURLEvent: UIEvent {
@@ -224,6 +227,30 @@ public class KeyboardShortcuts {
case .view: case .view:
return [ 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 // Toggle Dark Mode
UIKeyCommand( UIKeyCommand(
modifiers: [.command], input: "M", modifiers: [.command], input: "M",