From 4e88a27d9e90b4140b2b037304c26adf789315a3 Mon Sep 17 00:00:00 2001 From: sawka Date: Tue, 6 Aug 2024 19:46:53 -0700 Subject: [PATCH] fix zoom in/out to affect webcontents not webview --- emain/emain.ts | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/emain/emain.ts b/emain/emain.ts index 15618edf3..710378bd3 100644 --- a/emain/emain.ts +++ b/emain/emain.ts @@ -390,6 +390,9 @@ function createBrowserWindow( return { action: "deny" }; }); }); + win.webContents.on("before-input-event", (e, input) => { + // console.log("before-input-event", input); + }); win.on( "resize", debounce(400, (e) => mainResizeHandler(e, waveWindow.oid, win)) @@ -673,13 +676,34 @@ function makeAppMenu() { type: "separator", }, { - role: "resetZoom", + label: "Actual Size", + accelerator: "CommandOrControl+0", + click: (_, window) => { + window.webContents.setZoomFactor(1); + }, }, { - role: "zoomIn", + label: "Zoom In", + accelerator: "CommandOrControl+=", + click: (_, window) => { + window.webContents.setZoomFactor(window.webContents.getZoomFactor() + 0.2); + }, }, { - role: "zoomOut", + label: "Zoom In (hidden)", + accelerator: "CommandOrControl+Shift+=", + click: (_, window) => { + window.webContents.setZoomFactor(window.webContents.getZoomFactor() + 0.2); + }, + visible: false, + acceleratorWorksWhenHidden: true, + }, + { + label: "Zoom Out", + accelerator: "CommandOrControl+-", + click: (_, window) => { + window.webContents.setZoomFactor(window.webContents.getZoomFactor() - 0.2); + }, }, { type: "separator",