fix(desktop): enable default context menu for copy/paste across the app

This commit is contained in:
Mohamed Boudra
2026-04-01 19:19:40 +07:00
parent 963c79265a
commit b91884bc54
2 changed files with 15 additions and 1 deletions
+2
View File
@@ -17,6 +17,7 @@ import {
getWindowBackgroundColor,
resolveSystemWindowTheme,
setupWindowResizeEvents,
setupDefaultContextMenu,
setupDragDropPrevention,
} from "./window/window-manager.js";
import { registerDialogHandlers } from "./features/dialogs.js";
@@ -108,6 +109,7 @@ async function createMainWindow(): Promise<void> {
});
setupWindowResizeEvents(mainWindow);
setupDefaultContextMenu(mainWindow);
setupDragDropPrevention(mainWindow);
mainWindow.once("ready-to-show", () => {
mainWindow.show();
+13 -1
View File
@@ -1,4 +1,4 @@
import { app, BrowserWindow, ipcMain, nativeTheme } from "electron";
import { app, BrowserWindow, Menu, ipcMain, nativeTheme } from "electron";
export function readBadgeCount(input: unknown): number {
if (typeof input !== "number" || !Number.isSafeInteger(input) || input < 0) {
@@ -217,6 +217,18 @@ export function setupWindowResizeEvents(win: BrowserWindow): void {
});
}
export function setupDefaultContextMenu(win: BrowserWindow): void {
win.webContents.on("context-menu", (_event, params) => {
const menu = Menu.buildFromTemplate([
{ role: "copy", enabled: params.selectionText.length > 0 },
{ role: "paste" },
{ type: "separator" },
{ role: "selectAll" },
]);
menu.popup({ window: win });
});
}
/**
* Prevent Electron from navigating to files dragged onto the window.
* The renderer handles drag-drop via standard HTML5 APIs instead.