fix(desktop): enable default context menu for copy/paste across the app
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
|||||||
getWindowBackgroundColor,
|
getWindowBackgroundColor,
|
||||||
resolveSystemWindowTheme,
|
resolveSystemWindowTheme,
|
||||||
setupWindowResizeEvents,
|
setupWindowResizeEvents,
|
||||||
|
setupDefaultContextMenu,
|
||||||
setupDragDropPrevention,
|
setupDragDropPrevention,
|
||||||
} from "./window/window-manager.js";
|
} from "./window/window-manager.js";
|
||||||
import { registerDialogHandlers } from "./features/dialogs.js";
|
import { registerDialogHandlers } from "./features/dialogs.js";
|
||||||
@@ -108,6 +109,7 @@ async function createMainWindow(): Promise<void> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setupWindowResizeEvents(mainWindow);
|
setupWindowResizeEvents(mainWindow);
|
||||||
|
setupDefaultContextMenu(mainWindow);
|
||||||
setupDragDropPrevention(mainWindow);
|
setupDragDropPrevention(mainWindow);
|
||||||
mainWindow.once("ready-to-show", () => {
|
mainWindow.once("ready-to-show", () => {
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
|
|||||||
@@ -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 {
|
export function readBadgeCount(input: unknown): number {
|
||||||
if (typeof input !== "number" || !Number.isSafeInteger(input) || input < 0) {
|
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.
|
* Prevent Electron from navigating to files dragged onto the window.
|
||||||
* The renderer handles drag-drop via standard HTML5 APIs instead.
|
* The renderer handles drag-drop via standard HTML5 APIs instead.
|
||||||
|
|||||||
Reference in New Issue
Block a user