-
-
Save veloxy/c4ad51b5a01807cffb5e to your computer and use it in GitHub Desktop.
Electron tray: Drag and Drop events demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = require('app'); | |
var Menu = require('menu'); | |
var Tray = require('tray'); | |
var appIcon = null; | |
app.on('ready', function(){ | |
// image is null, so image will not be shown in menu bar | |
// so click around on the system menu bar to locate the space where the tray icon is | |
appIcon = new Tray(null); | |
var contextMenu = Menu.buildFromTemplate([ | |
{ label: 'Item1', type: 'radio' }, | |
{ label: 'Item2', type: 'radio' }, | |
{ label: 'Item3', type: 'radio', checked: true }, | |
{ label: 'Item4', type: 'radio' } | |
]); | |
appIcon.setToolTip('This is my application.'); | |
appIcon.setContextMenu(contextMenu); | |
appIcon.on('drag-enter', function() { | |
console.log('drag-enter!'); | |
}); | |
appIcon.on('drag-leave', function() { | |
console.log('drag-leave!'); | |
}); | |
appIcon.on('drag-end', function() { | |
console.log('drag-end!'); | |
}); | |
appIcon.on('drop', function() { | |
console.log('drop!'); | |
}); | |
appIcon.on('drop-files', function(event, files) { | |
console.log('drop-files!'); | |
// Array with file paths! | |
console.log(files); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment