Skip to content

Commit

Permalink
add context menu to copy URL or quit
Browse files Browse the repository at this point in the history
  • Loading branch information
cesque committed Aug 1, 2019
1 parent f4e718e commit a04fe7a
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { createError } = require('micro')
const path = require('path')
const fs = require('fs')
const internalip = require('internal-ip')
const { clipboard, nativeImage } = require('electron')
const { clipboard, nativeImage, Menu } = require('electron')

const PORT = 4500

Expand Down Expand Up @@ -72,13 +72,24 @@ mb.on('ready', async () => {

mb.tray.setTitle('drop')
mb.tray.setImage('./icon.png')

let contextMenu = Menu.buildFromTemplate([
{
label: 'Copy URL',
click: () => {
clipboard.writeText('http://' + ip + ':' + PORT)
},
},
{
label: 'Quit',
role: 'quit',
}
])

mb.tray.setContextMenu(contextMenu)

mb.tray.removeAllListeners('click')

mb.tray.on('click', event => {
clipboard.writeText('http://' + ip + ':' + PORT)
})

mb.tray.on('drop-files', (event, dropped) => {

for(let file of dropped) {
Expand Down

0 comments on commit a04fe7a

Please sign in to comment.