Can not use Drag and Drop File with FileDragAndDropTarget


#1

I used JUCE 5.2.0 I just created an area to drag and drop file there, I wrote a class inheritance from FileDragAndDropTarget. I run the app and dropped file there but function isInterestedInFileDrag wasn’t called? Does anyone help me why it was?


#2

It’s hard to say without seeing any of your code but make sure that one of the Components in the parent hierarchy of your FileDragAndDropTarget derives from DragAndDropContainer.


#3

Thank you for your reply.
Here is my code link
I used JUCE 5.2.0.
I dont know why the function isInterestedInFileDrag() wasn’t called when i drag a file.
Thanks,


#4

Maybe it was a copy/paste error when you put it into the google doc, but I don’t think it compiled.
The paint method is missing the g as argument. The compiler would have complained, when you called g.fillAll (...) in paint.
Also it is not required, but you should add the keyword override after paint() and resized().

Can you double check, if it is actually running that code and not an outdated build without the FileDragAndDropTarget?


#5

Sorry for my copy mistakes. Please help me view this code link
I’ve built and run this code.
Thanks,


#6

Hi @daniel, is there any error with my code?
I can run it but the function isInterestedInFileDrag() wasn’t called. :frowning: !


#7

I’ve just run your code and isInterestedInFileDrag() is being called when I drag a file over the Component. What platform is this on? Can you also try running your app with the latest tip of develop.


#8

Thank @ed95, I’ve run the run code but isInterestedInFileDrag() wasn’t called. Did you run code with JUCE 5.2.0?


#9

Yes. What platform are you on?


#10

I run on Windows 10


#11

OK I’ve just tried it on Windows 10 and it works fine, I’m really not sure what else to suggest here. Have you actually put a breakpoint in isInterestedInFileDrag() to see if it gets called when you hover a file over the window?


#12

@ed95 Did you use Juce 5.2.0?


#13

Yes


#14

Thank you so much @ed95, I don’t know why but I’ll debug my program again. Thank so much for you replies :slight_smile: