This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Drag and drop on to an ImageView  RSS feed

 
Colin Smithworth
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm trying to enable being able to drag and drop files from the windows desktop to an ImageView inside my gui.

When I try this, I get a red circle with a line through showing by the file as I move it over the ImageView.

However...

If I press on the ImageView prior to dragging a file over it, then it works.


I'm not sure whats going on exactly, I'm essentially using this code for the drag over part:



So the "db has things!" line never shows when dragging over, unless I press on the ImageView first.

I'm not sure whats going on, any ideas please, thanks.
 
L Foster
Ranch Hand
Posts: 242
14
Android Angular Framework AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Colin.  Here is a simplistic explanation, which just _might_ be true. Could this be simply that you have caused your app to gain focus, prior to doing the mouseover?  Also, I think the "line-through" thing is just DnD's way of saying "this target is not accepting this type".  I hope that helps.
 
Colin Smithworth
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
L Foster wrote:Hi, Colin.  Here is a simplistic explanation, which just _might_ be true. Could this be simply that you have caused your app to gain focus, prior to doing the mouseover?  Also, I think the "line-through" thing is just DnD's way of saying "this target is not accepting this type".  I hope that helps.


Thanks for the reply...

Well the window with the ImageView is a second stage, if I move this window first by dragging it at the top, then when I drag and drop onto the ImageView, nothing happens.
I have to literally press somewhere on the window first, then I am allowed to drag and drop.

I would think the window being focused would be required for the drag and drop, I tried ImageView.requestFocus(), after it is created, but that doesn't make any difference.

Maybe it has something to do with the other stage, if I press on that, then the drag and drop also works on this stage.

Let me know if you have any thoughts, thanks.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!