Skip to content

Instantly share code, notes, and snippets.

@veloxy
Forked from nishanths/main.js
Created March 9, 2016 11:59
Show Gist options
  • Save veloxy/c4ad51b5a01807cffb5e to your computer and use it in GitHub Desktop.
Save veloxy/c4ad51b5a01807cffb5e to your computer and use it in GitHub Desktop.
Electron tray: Drag and Drop events demo
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