# Drag and drop not accepted by canvas or imagewell

**URL:** <https://forum.xojo.com/t/drag-and-drop-not-accepted-by-canvas-or-imagewell/17020>\
**Category:** Getting Started\
**Created:** [June 4, 2014, 8:38am UTC](https://forum.xojo.com/t/drag-and-drop-not-accepted-by-canvas-or-imagewell/17020 "2014-06-04T08:38:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Blazek](https://forum.xojo.com/letter_avatar_proxy/v4/letter/r/c68b51/32.png) [@Robert\_Blazek](https://forum.xojo.com/u/Robert_Blazek)\
**Post date:** [June 4, 2014, 8:38am UTC](https://forum.xojo.com/t/drag-and-drop-not-accepted-by-canvas-or-imagewell/17020/1 "2014-06-04T08:38:21Z")

</div>

I wrote in the open-Event of the canvas

` Me.AcceptPictureDrop
  me.AcceptFileDrop("image/jpeg")`  
and as it is written in all pages I looked at - i wrote into the dropobjekt-event

` If Obj.PictureAvailable Then
    Me.backdrop = obj.Picture
  ElseIf Obj.FolderItemAvailable Then
    Me.backdrop = Picture.Open(obj.FolderItem)
  End If`  
But all pictures are refused by the canvas.  
(Taking it from DeskTop) - System Windows 8.1  
Is there any other thing I have to do?

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [June 4, 2014, 10:29am UTC](https://forum.xojo.com/t/drag-and-drop-not-accepted-by-canvas-or-imagewell/17020/2 "2014-06-04T10:29:21Z")

</div>

Did you define a file type for `"image/jpeg"` ?

OK: I do what you said and it does not works (here) too.

So, I added a File Type Set (menu Insert) for `"image/jpeg"`. It does not works too.

So, I checked what I had in front of me to discover that the Open Event I fill with your code was Window1, not Canvas1 \*

Once I put the code in Canvas1.DropObject, and run, it worked fine (btw: I commented out the line `Me.AcceptPictureDrop` ).

- When I wrote I feel insecure when using Xojos IDE, I was right ! The Intended DropObject Event to fill with code does not go to the Canvas Control, but to Window1 !

And in a project with7 lines !!!

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [June 4, 2014, 1:16pm UTC](https://forum.xojo.com/t/drag-and-drop-not-accepted-by-canvas-or-imagewell/17020/3 "2014-06-04T13:16:36Z")

</div>

[quote=95219:@Emile Schwarz]Did you define a file type for `"image/jpeg"` ?

OK: I do what you said and it does not works (here) too.

So, I added a File Type Set (menu Insert) for `"image/jpeg"`. It does not works too.

So, I checked what I had in front of me to discover that the Open Event I fill with your code was Window1, not Canvas1 \*

Once I put the code in Canvas1.DropObject, and run, it worked fine (btw: I commented out the line `Me.AcceptPictureDrop` ).

- When I wrote I feel insecure when using Xojos IDE, I was right ! The Intended DropObject Event to fill with code does not go to the Canvas Control, but to Window1 !

And in a project with7 lines !!![/quote]

The OP uses Windows, which is kind of picky as far as drag and drop is concerned.

But the first thing I would try indeed would be to try adding a FileTypes to the project, add JPeg to it, and write line 2 as :

```auto
  me.AcceptFileDrop(FileTypes1.Jpeg)
```

---

<div class="post-metadata">

**Author:** ![Robert\_Blazek](https://forum.xojo.com/letter_avatar_proxy/v4/letter/r/c68b51/32.png) [@Robert\_Blazek](https://forum.xojo.com/u/Robert_Blazek)\
**Post date:** [June 4, 2014, 2:29pm UTC](https://forum.xojo.com/t/drag-and-drop-not-accepted-by-canvas-or-imagewell/17020/4 "2014-06-04T14:29:48Z")

</div>

Trying this out, I must say: I dant see the canvas in Runtime. Is this normal?  
May be the drag and drop would work, but with no canvas there?

---

<div class="post-metadata">

**Author:** ![Robert\_Blazek](https://forum.xojo.com/letter_avatar_proxy/v4/letter/r/c68b51/32.png) [@Robert\_Blazek](https://forum.xojo.com/u/Robert_Blazek)\
**Post date:** [June 4, 2014, 2:31pm UTC](https://forum.xojo.com/t/drag-and-drop-not-accepted-by-canvas-or-imagewell/17020/5 "2014-06-04T14:31:58Z")

</div>

Now it worked - so I have to draw a rectangle around the canvas to mark it and the user can put a picture into this box.

---

<div class="post-metadata">

**Author:** ![Robert\_Blazek](https://forum.xojo.com/letter_avatar_proxy/v4/letter/r/c68b51/32.png) [@Robert\_Blazek](https://forum.xojo.com/u/Robert_Blazek)\
**Post date:** [June 4, 2014, 4:54pm UTC](https://forum.xojo.com/t/drag-and-drop-not-accepted-by-canvas-or-imagewell/17020/6 "2014-06-04T16:54:12Z")

</div>

After reading through some comments I think, now after having a picture dropped in the canvas, I cannot store it into the database - or?

---

<div class="post-metadata">

**Author:** ![Matthew\_Combatti](https://forum.xojo.com/user_avatar/forum.xojo.com/matthew_combatti/32/635_2.png) [@Matthew\_Combatti](https://forum.xojo.com/u/Matthew_Combatti)\
**Post date:** [June 4, 2014, 5:52pm UTC](https://forum.xojo.com/t/drag-and-drop-not-accepted-by-canvas-or-imagewell/17020/7 "2014-06-04T17:52:35Z")

</div>

Dim dbPic as Picture = CanvasName.BackDrop

And store the picture as normal in a database (blob) or field as PictureValue.

---

<div class="post-metadata">

**Author:** ![Robert\_Blazek](https://forum.xojo.com/letter_avatar_proxy/v4/letter/r/c68b51/32.png) [@Robert\_Blazek](https://forum.xojo.com/u/Robert_Blazek)\
**Post date:** [June 5, 2014, 6:17am UTC](https://forum.xojo.com/t/drag-and-drop-not-accepted-by-canvas-or-imagewell/17020/8 "2014-06-05T06:17:01Z")

</div>

thks

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:15pm UTC](https://forum.xojo.com/t/drag-and-drop-not-accepted-by-canvas-or-imagewell/17020/9 "2020-10-29T17:15:21Z")

</div>


