mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-22 02:12:30 +01:00
parent
351b8673ee
commit
999e855254
30
public/contextMenu.js
Normal file
30
public/contextMenu.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
const { Menu } = require('electron');
|
||||||
|
|
||||||
|
// https://github.com/electron/electron/issues/4068#issuecomment-274159726
|
||||||
|
module.exports = (window) => {
|
||||||
|
const selectionMenu = Menu.buildFromTemplate([
|
||||||
|
{ role: 'copy' },
|
||||||
|
{ type: 'separator' },
|
||||||
|
{ role: 'selectall' },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const inputMenu = Menu.buildFromTemplate([
|
||||||
|
{ role: 'undo' },
|
||||||
|
{ role: 'redo' },
|
||||||
|
{ type: 'separator' },
|
||||||
|
{ role: 'cut' },
|
||||||
|
{ role: 'copy' },
|
||||||
|
{ role: 'paste' },
|
||||||
|
{ type: 'separator' },
|
||||||
|
{ role: 'selectall' },
|
||||||
|
]);
|
||||||
|
|
||||||
|
window.webContents.on('context-menu', (e, props) => {
|
||||||
|
const { selectionText, isEditable } = props;
|
||||||
|
if (isEditable) {
|
||||||
|
inputMenu.popup(window);
|
||||||
|
} else if (selectionText && selectionText.trim() !== '') {
|
||||||
|
selectionMenu.popup(window);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
@ -16,6 +16,7 @@ const logger = require('./logger');
|
|||||||
const menu = require('./menu');
|
const menu = require('./menu');
|
||||||
const configStore = require('./configStore');
|
const configStore = require('./configStore');
|
||||||
const { frontendBuildDir } = require('./util');
|
const { frontendBuildDir } = require('./util');
|
||||||
|
const attachContextMenu = require('./contextMenu');
|
||||||
|
|
||||||
const { checkNewVersion } = require('./update-checker');
|
const { checkNewVersion } = require('./update-checker');
|
||||||
|
|
||||||
@ -108,6 +109,8 @@ function createWindow() {
|
|||||||
|
|
||||||
remote.enable(mainWindow.webContents);
|
remote.enable(mainWindow.webContents);
|
||||||
|
|
||||||
|
attachContextMenu(mainWindow);
|
||||||
|
|
||||||
|
|
||||||
if (isDev) mainWindow.loadURL('http://localhost:3001');
|
if (isDev) mainWindow.loadURL('http://localhost:3001');
|
||||||
// Need to useloadFile for special characters https://github.com/mifi/lossless-cut/issues/40
|
// Need to useloadFile for special characters https://github.com/mifi/lossless-cut/issues/40
|
||||||
|
Loading…
Reference in New Issue
Block a user