Browse Source

Merge pull request #270 from LN-Zap/fix/payinput-paste

fix(input): give feature full menu for inputs
renovate/lint-staged-8.x v0.1.1-beta
JimmyMow 7 years ago
committed by GitHub
parent
commit
9e5f82a7c3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 44
      app/menu.js

44
app/menu.js

@ -21,28 +21,48 @@ export default class MenuBuilder {
template = this.buildDefaultTemplate()
}
this.setupInputTemplate()
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
return menu
}
setupDevelopmentEnvironment() {
this.mainWindow.openDevTools()
setupInputTemplate() {
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' }
])
this.mainWindow.webContents.on('context-menu', (e, props) => {
const { x, y } = props
Menu
.buildFromTemplate([{
label: 'Inspect element',
click: () => {
this.mainWindow.inspectElement(x, y)
}
}])
.popup(this.mainWindow)
const { selectionText, isEditable } = props
if (isEditable) {
inputMenu.popup(this.mainWindow)
} else if (selectionText && selectionText.trim() !== '') {
selectionMenu.popup(this.mainWindow)
}
})
}
setupDevelopmentEnvironment() {
this.mainWindow.openDevTools()
}
buildDarwinTemplate() {
const subMenuAbout = {
label: 'Electron',

Loading…
Cancel
Save