ui: missing context menu (copy, paste) in inspector inputs

This commit is contained in:
bordun 2020-11-09 12:14:02 +01:00
parent a6d4d51559
commit 268b9f9be5
3 changed files with 16 additions and 2 deletions

View file

@ -1,5 +1,5 @@
var path = require('path'),
{BrowserWindow, dialog, shell, screen} = require('electron'),
{BrowserWindow, dialog, shell, screen, Menu, MenuItem} = require('electron'),
shortcut = require('electron-localshortcut'),
app = require('./electron-app'),
settings = require('./settings'),
@ -131,6 +131,15 @@ module.exports = function(options={}) {
settings.write('geometry', geometry)
})
var menu = new Menu()
menu.append(new MenuItem({role: 'copy'}))
menu.append(new MenuItem({role: 'paste'}))
window.webContents.on('context-menu', (e, data) => {
menu.items[0].enabled = data.editFlags.canCopy
menu.items[1].enabled = data.editFlags.canPaste
menu.popup({window: window, x: e.x, y: e.y })
}, false)
if (options.shortcuts) {
shortcut.register(window,'CmdOrCtrl+R',function(){