Skip to content

Instantly share code, notes, and snippets.

@nishanths
Last active August 7, 2019 23:46
Show Gist options
  • Save nishanths/42eb1c00445f87a2dd6d to your computer and use it in GitHub Desktop.
Save nishanths/42eb1c00445f87a2dd6d 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!');
});
});
@nishanths
Copy link
Author

Also, this is referenced in this atom/electron pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment