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

@ -2,6 +2,9 @@
## 1.6.3
- bug fixes
- missing context menu (copy, paste) in inspector inputs
- widgets
- keyboard: add `velocity` property (allows mapping the touch coordinates between `off` (top) and `on` (bottom))

View file

@ -17,7 +17,9 @@ if (macOs) {
DOM.dispatchEvent(event.target, 'fast-right-click', event)
})
} else {
document.body.setAttribute('oncontextmenu', 'return false')
document.body.addEventListener('contextmenu', (event)=>{
if (event.target && (!event.target.tagName.match(/INPUT|TEXTAREA|OSC-CONSOLE|OSC-CONSOLE-MESSAGE/))) event.preventDefault()
})
}
function mouseToFastClick(event) {

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(){