Added menu when right clicking inputs.
This commit is contained in:
parent
6f819d53ba
commit
a616c2f820
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue