Closed
Description
So I followed the basic use case: https://github.com/atom/electron/blob/master/docs/api/file-object.md
However for some reason none of those events fire, I have tried applying them to a containing div, an empty div, the document, the body. The events are never fired (I put a console.log as first line in all of them).
Is there anything special you have to do other than just get an DOM element and listen for those events?
I am running version 0.30.0 on windows 8.1.
Activity
hokein commentedon Jul 24, 2015
The
default_app
in Electron is a good sample for usage ofFile
object, could you refer to it? It maybe helpful for you.grofit commentedon Jul 24, 2015
its same code, but will give it a go in isolation and see if it has same issues.
grofit commentedon Jul 25, 2015
Well the default app seems to work, which baffles me as I dont know how I do not get events fired yet I am using exactly the same code, the only differences are:
Here is the basic usage:
Now I see the SETUP output in the console so I know it has started it, but there is never any output for DRAGGING, NOT DRAGGING or DROPPING when trying to drag and drop a file over the element.
zcbenz commentedon Jul 28, 2015
@grofit Can you give a full example? Also the best way to determine whether it is a bug of Electron is to test your code in Chrome browser directly.
grofit commentedon Jul 28, 2015
Well the odd thing is it works now, but I have not changed anything related to it, other than restarting the computer. So I don't know what caused it, and it worries me slightly that it magically started working.
Now I have a new issue where drag and drop events fire on child elements making it a massive event mess, but thats not related to this issue. So you can close this now.
grofit commentedon Jul 28, 2015
HEY!
So it ended up happening again after a refactor and I compared what was different and it turns out that this is what was causing it (I think).
http://stackoverflow.com/questions/21339924/drop-event-not-firing-in-chrome
So it seems that you need to
preventDefault
on dragging events or it just seems to ignore drop events.Only wanted to post it here incase anyone else had the seemingly random issue.
elicore commentedon Nov 10, 2015
I'm getting something similar. Tried copying the default_app code and it didn't work, then I tried the default_app itself and I can't drag anything there either. The same index.html file I'm using with the default_app code works well when opened in Chrome.
Using Electron 0.34.0 on Windows 10.
Lokua commentedon Nov 17, 2015
Same thing here.
Electron 0.35.0
Windows 10
HenryVonfire commentedon Feb 19, 2016
It happens to me too in windows 10 but the same application (a simple drag and drop) works fine in Linux.
jkudish commentedon Mar 4, 2016
Having the same problem on Windows 10 as well. Dropping a file doesn't work.
mihaipanait commentedon Jun 3, 2016
I get the same icon indicating the dropping isn't allowed, but only when i run the npm command (to start the electron app) inside an elevated cmd prompt on windows. If i don't run it as admin, then drag and drop works fine. It might be related to this:
https://blogs.msdn.microsoft.com/patricka/2010/01/28/q-why-doesnt-drag-and-drop-work-when-my-application-is-running-elevated-a-mandatory-integrity-control-and-uipi/
kerryChen95 commentedon Oct 19, 2016
Similar problem on Windows10/Electron1.4.1, I have cancelled
dragover
anddragenter
events,drop
event not fire,dragend
event fire. But the same code works on Chrome53.voodle-automaton commentedon Dec 5, 2016
So has anyone gotten Windows 10 Electron apps to accept dragged files?
Armaldio commentedon Dec 5, 2016
@scottpixvana https://gist.github.com/armaldio/75ae2b6476da83110cf8d54d47e89b56