Handling drop object event

How do I see if the type of object that has been dragged in is a picture or file dropped in using an if statement. And then how do I get the picture from that? I have read the docs and I seem to be missing something. It seems that pictures are dragged in as ‘PrivateRawData’ but how do I use that for any kind of picture that is compatible with the canvas object??

Thanks

This is the code from RectControl.DropObject:

If Obj.PictureAvailable Then Me.Image = obj.Picture ElseIf Obj.FolderItemAvailable Then Me.Image = Picture.Open(obj.FolderItem) End If

Does it not do what you want?

[quote=44496:@Paul Lefebvre]This is the code from RectControl.DropObject:

If Obj.PictureAvailable Then Me.Image = obj.Picture ElseIf Obj.FolderItemAvailable Then Me.Image = Picture.Open(obj.FolderItem) End If

Does it not do what you want?[/quote]
It apears to accept the picture that I dragged from google chrome but obj.pictureavailable returns false?

[quote=44496:@Paul Lefebvre]This is the code from RectControl.DropObject:

If Obj.PictureAvailable Then Me.Image = obj.Picture ElseIf Obj.FolderItemAvailable Then Me.Image = Picture.Open(obj.FolderItem) End If

Does it not do what you want?[/quote]
It seems that with just ‘me.AcceptRawDataDrop(“text”)’, it will accept pictures dragged in from chrome but i do not know how to handle them.

Don’t use AcceptRawDataDrop. Use AcceptPictureDrop and AcceptFileDrop together instead.

It does not seem to execute the event if I do not use AcceptRawDataDrop?

It’s worth remembering that it’s the application from which you are dragging, not Xojo’s runtime, that constructs the dragItem. Different applications may do this differently, and you need to be prepared to gracefully handle any eventuality in your app’s droppedObject events. Do this by checking that obj itself is not NIL, and then check each possible obj.xxxAvailable property to see if the dragItem contains a particular type of data.

For example, it you drag a picture from Safari, both obj.textAvailable and obj.pictureAvailable are true. The obj.picture property contains the picture itself, and the text property contains its url. Do the same thing from a page in Chrome, and only the picture property contains data; obj.textAvailable is false. (At least this is the case with Safari and Chrome on the Mac.)

From what you report, Oliver, it seems that you have been dragging from an application that uses the RawData property of the dragItem to store picture data. If that’s the case, then the obj.picture property may be nil…

[quote=44961:@Peter Truskier]It’s worth remembering that it’s the application from which you are dragging, not Xojo’s runtime, that constructs the dragItem. Different applications may do this differently, and you need to be prepared to gracefully handle any eventuality in your app’s droppedObject events. Do this by checking that obj itself is not NIL, and then check each possible obj.xxxAvailable property to see if the dragItem contains a particular type of data.

For example, it you drag a picture from Safari, both obj.textAvailable and obj.pictureAvailable are true. The obj.picture property contains the picture itself, and the text property contains its url. Do the same thing from a page in Chrome, and only the picture property contains data; obj.textAvailable is false. (At least this is the case with Safari and Chrome on the Mac.)

From what you report, Oliver, it seems that you have been dragging from an application that uses the RawData property of the dragItem to store picture data. If that’s the case, then the obj.picture property may be nil…[/quote]
Thanks but how do I get hold of this picture if it is of the RawData type?

[quote=44961:@Peter Truskier]It’s worth remembering that it’s the application from which you are dragging, not Xojo’s runtime, that constructs the dragItem. Different applications may do this differently, and you need to be prepared to gracefully handle any eventuality in your app’s droppedObject events. Do this by checking that obj itself is not NIL, and then check each possible obj.xxxAvailable property to see if the dragItem contains a particular type of data.

For example, it you drag a picture from Safari, both obj.textAvailable and obj.pictureAvailable are true. The obj.picture property contains the picture itself, and the text property contains its url. Do the same thing from a page in Chrome, and only the picture property contains data; obj.textAvailable is false. (At least this is the case with Safari and Chrome on the Mac.)

From what you report, Oliver, it seems that you have been dragging from an application that uses the RawData property of the dragItem to store picture data. If that’s the case, then the obj.picture property may be nil…[/quote]
I think you might be right, thanks.

[quote=44961:@Peter Truskier]It’s worth remembering that it’s the application from which you are dragging, not Xojo’s runtime, that constructs the dragItem. Different applications may do this differently, and you need to be prepared to gracefully handle any eventuality in your app’s droppedObject events. Do this by checking that obj itself is not NIL, and then check each possible obj.xxxAvailable property to see if the dragItem contains a particular type of data.

For example, it you drag a picture from Safari, both obj.textAvailable and obj.pictureAvailable are true. The obj.picture property contains the picture itself, and the text property contains its url. Do the same thing from a page in Chrome, and only the picture property contains data; obj.textAvailable is false. (At least this is the case with Safari and Chrome on the Mac.)

From what you report, Oliver, it seems that you have been dragging from an application that uses the RawData property of the dragItem to store picture data. If that’s the case, then the obj.picture property may be nil…[/quote]
You fixed it, I think. Thankyou so much!!

Were you able to extract an image from the dragitem? On Windows, you don’t appear to get a PictureAvailable. Chrome gives you the url in the text. IE doesn’t even give you that. What would you use in RawData to get at the image?