Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #270 from LN-Zap/fix/payinput-paste
Browse files Browse the repository at this point in the history
fix(input): give feature full menu for inputs
  • Loading branch information
JimmyMow authored Jan 31, 2018
2 parents e85eb85 + b3aaeb4 commit 9e5f82a
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions app/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 9e5f82a

Please sign in to comment.