This commit is contained in:
2026-03-08 21:53:36 +11:00
parent 386cfc7710
commit 22378c001e
2 changed files with 27 additions and 6 deletions

2
cinny

Submodule cinny updated: b185e0b129...30a7725769

View File

@@ -326,12 +326,12 @@ function createWindow() {
} }
}, { useSystemPicker: false }); }, { useSystemPicker: false });
// Disable default context menu, only show for text selection // Disable default context menu, only show for text selection and images
mainWindow.webContents.on('context-menu', (event, params) => { mainWindow.webContents.on('context-menu', (event, params) => {
const { selectionText, isEditable } = params; const { selectionText, isEditable, mediaType, srcURL } = params;
// Only show context menu if there's selected text or in an editable field // Show context menu for text selection, editable fields, or images
if (selectionText || isEditable) { if (selectionText || isEditable || mediaType === 'image') {
// Build a minimal menu for text operations // Build a minimal menu for text operations
const template = []; const template = [];
@@ -348,6 +348,27 @@ function createWindow() {
} }
} }
// Image context menu options
if (mediaType === 'image' && srcURL) {
template.push(
{
label: 'Copy Image',
click: () => {
mainWindow.webContents.copyImageAt(params.x, params.y);
}
},
{
label: 'Save Image As...',
click: () => {
mainWindow.webContents.downloadURL(srcURL);
}
}
);
if (selectionText) {
template.push({ type: 'separator' });
}
}
if (selectionText) { if (selectionText) {
template.push( template.push(
{ {
@@ -392,7 +413,7 @@ function createWindow() {
menu.popup(mainWindow); menu.popup(mainWindow);
} }
} }
// If no text selected and not editable, suppress the context menu entirely // If no text selected, not editable, and not an image, suppress the context menu entirely
}); });
// Load the app // Load the app