From 59a2b9b787c8078d132a3e264110a0fd2b73aa5c Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Mon, 26 Aug 2024 13:30:19 -0700 Subject: [PATCH] Replace default edit menu with one that won't eat keyboard shortcuts (#274) We only need global Cut/Copy/Paste accelerators on macOS. Linux and Windows do these automatically. Additionally, having these accelerators means that we can't use shortcuts like Ctrl+C in the terminal. This PR removes these accelerators for every platform but macOS. --- emain/emain.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/emain/emain.ts b/emain/emain.ts index 66a1cde02..1932c7fd5 100644 --- a/emain/emain.ts +++ b/emain/emain.ts @@ -691,6 +691,43 @@ function getAppMenu() { appMenu.push({ role: "quit", }); + const editMenu: Electron.MenuItemConstructorOptions[] = [ + { + role: "undo", + accelerator: unamePlatform === "darwin" ? "Command+Z" : "", + }, + { + role: "redo", + accelerator: unamePlatform === "darwin" ? "Command+Shift+Z" : "", + }, + { + type: "separator", + }, + { + role: "cut", + accelerator: unamePlatform === "darwin" ? "Command+X" : "", + }, + { + role: "copy", + accelerator: unamePlatform === "darwin" ? "Command+C" : "", + }, + { + role: "paste", + accelerator: unamePlatform === "darwin" ? "Command+V" : "", + }, + { + role: "pasteAndMatchStyle", + accelerator: unamePlatform === "darwin" ? "Command+Shift+V" : "", + }, + { + role: "delete", + }, + { + role: "selectAll", + accelerator: unamePlatform === "darwin" ? "Command+A" : "", + }, + ]; + const viewMenu: Electron.MenuItemConstructorOptions[] = [ { role: "forceReload", @@ -763,6 +800,7 @@ function getAppMenu() { }, { role: "editMenu", + submenu: editMenu, }, { role: "viewMenu",