News for hackers. Stuff that matters.
Re:How Four Native Developers Wrote an Electron App by adnzzzzZ on Friday May 19, 2017 @12:52AM (#14373112)
Re:How Four Native Developers Wrote an Electron App by ridiculous_fish on Friday May 19, 2017 @01:37AM (#14373271)
Based on that link, Electron drag and drop seems extremely limited compared to what native APIs provide:

1. No way to declare what drop types you accept

2. No way to validate the contents of the drop before it occurs

3. No way to provide a visual indication of the action of the drop (copy, move, link...)

4. No way to generate a file drag

5. No drag promises

6. No custom drag images

This seems like the typical web development story: quick to build a low-quality implementation, impossible to build a good one.

Re:How Four Native Developers Wrote an Electron App by bhanu423 on Friday May 19, 2017 @02:18AM (#14373378)
How to solve the issues above: Just listen to 'ondrop' event on body and store the path of the file and call event.preventDefault() to prevent the file loading. Now I think all of your issues are solved:

>1: You can now filter the extensions as per your requirements

>2: Now you can load the file separately and verify the content as per your satisfaction using the fs module available in electron

>3: You can use: ondragover and ondragend events to facilitate ui feedback

>4: Not sure what you mean by file drag, but I cannot think of anything that cannot be implemented here.

>5: Not sure what do you want here.

>6: Not inbuilt but can be built easily.

Editors like atom and vscode have very good file-drop functionality and have image viewer apart from many other goodies. Depending on your familiarity with js, these things are more or less trivial to implement. Github team must have a different feature-set in mind that unfortunately didn't had drag and drop functionality for their first release. If anyone really wants the feature, the better way is to leave a feedback in app or open a issue (not sure if either exists).

Re:How Four Native Developers Wrote an Electron App by pjmlp on Friday May 19, 2017 @02:28AM (#14373409)
> quick to build a low-quality implementation, impossible to build a good one.

You just gave me a new quote to use. :)