Added menu when right clicking inputs.

This commit is contained in:
Mikunj Varsani 2019-06-07 10:11:28 +10:00
parent 6f819d53ba
commit a616c2f820
1 changed files with 23 additions and 0 deletions

View File

@ -20,6 +20,20 @@ let mainWindow, backend
let showConfirmClose = true
let forceQuit = false
const selectionMenu = Menu.buildFromTemplate([
{ role: "copy" },
{ type: "separator" },
{ role: "selectall" }
])
const inputMenu = Menu.buildFromTemplate([
{ role: "cut" },
{ role: "copy" },
{ role: "paste" },
{ type: "separator" },
{ role: "selectall" }
])
const portInUse = function (port, callback) {
var server = net.createServer(function (socket) {
socket.write("Echo server\r\n")
@ -127,6 +141,15 @@ function createWindow () {
})
})
mainWindow.webContents.on("context-menu", (e, props) => {
const { selectionText, isEditable } = props
if (isEditable) {
inputMenu.popup(mainWindow)
} else if (selectionText && selectionText.trim() !== "") {
selectionMenu.popup(mainWindow)
}
})
mainWindow.loadURL(process.env.APP_URL)
mainWindowState.manage(mainWindow)
}