Last active
August 7, 2019 23:46
-
-
Save nishanths/42eb1c00445f87a2dd6d 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!'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For the people who end up here through google wondering how to drag and drop files 😊