Using AppJS (http://appjs.org/) which basically gives NodeJS a webkit window to work with. I am attempting to harness the drag and drop event for files and URLs to be used in my code.
The short code for the drag and drop can be found here: https://github.com/appjs/appjs/wiki/HTML5:-Drag-&-Drop-from-Desktop
The code I have used to create the window:
var app_window = appjs.createWindow({
width : 200,
height : 200,
showChrome : true, //display as standard os window with max/min/close buttons
alpha: false,
autoResize: true, //adjust window size automatically according to content.
resizable: true, //allow user resize of window
margin: 0,
disableSecurity:true, //turn off security restrictions.
showResizeGrip:false, //show/hide the resize grip.
name:'Drag and Drop', //undocumented parameter
opacity:1,
fullscreen:false,
topmost:true
});
the event handler code:
var window_drop = function(event) { // this code never fires.
event.preventDefault();
console.log('drop event');
};
and the code I have set for firing the event:
app_window.on('ready', function() {
app_window.require = require;
app_window.process = process;
app_window.module = module;
app_window.console = console;
app_window.frame.show();
app_window.frame.center();
app_window.addEventListener("drop", window_drop);
});
Specs: I am running NodeJS 32 bit (required by AppJS) on Mac OSX Lion.
I know that AppJS is in it's infancy but this should work.
What could be the problem? Why is the event never fired?
I'm not entirely sure why your method isn't working, but try the method I use (and it works):-
In your main html, add the script tag there and then attach your drop event inside the app-ready event as shown below: