Drag-and-dropping of files

How would one go about letting users drop a file onto my program’s window and getting the path to it? I’ve done this in the past in Adobe AIR apps made in AS3, is there a way to do this for Neko/CPP applications with OpenFL? Often times this is more convenient than a file selection dialogue or something.

window.dropFile should work on the desktop

http://api.openfl.org/lime/ui/Window.html#onDropFile

Something like

stage.window.onDropFile.add (function (path:String) {
   trace ("user dropped file with path: " + path);
});

Thanks, works perfectly! I’ll have to look into the Lime library a bit more, it seems to have a lot of stuff for desktop applications.

@singmajesty Is there any way for us to update the docs to include this example (pull-request)?
http://api.openfl.org/lime/ui/Window.html#onDropFile

1 Like