Xojos' own drag and drop example not working

Hi I am running Xojo 2014 version 1.1

I have run and then compiled the example Desktop >> DragAndDrop >> ListBoxDragAndDrop for the Mac and windows on a Mac itself.

My problem is that dragging and dropping works flawlessly on the Mac BUT on windows its a total failure (displaying a small no entry symbol when trying)

This was the very first todo item on a project I am starting and it failed, I spent 2 hours searching the web and trying all the examples but to no avail.

Has anyone got any suggestions, so far this hasn’t been a great experience.

Thank you.

p.s
Mac OS is 10.9.2
Win 7
and I’m trying to drag and drop images

The syntax is slightly different on Windows. In MainWindow -> Controls -> FileList -> Open, replace

Me.AcceptFileDrop("")

with

Me.AcceptFileDrop("special/any;")

I don’t know if that works on Mac, but it probably should.

I tried that now, am still battling with it - am afraid it didn’t work.

I dont understand why this is working out the box, I wonder if the examples have actually been tested to work cross platform, otherwise it defeats the purpose of using this software tech, if it doesn’t work.

Am running out of ideas now.

Thanks.

The example project you picked is not for images but for dragging text between the two boxes.

If you want to drop images, create a project with a canvas, and in the Open event, add what Tim Hare told you :

Me.AcceptFileDrop("special/any;")

In the DropObject event :

Me.Backdrop = Picture.Open(Obj.FolderItem)

Be careful, there is no filter that prevents you from dropping non-image files over. You want to add something like :

If right(Obj.FolderItem.Name,4) = ".png" or right(Obj.FolderItem.Name,5) = ".jpeg" then Me.Backdrop = Picture.Open(Obj.FolderItem) end if

With all the image extensions you intend to use, so non-pictures will not create an error.

You may want to rest your canvas on top of a Group Box to see where it is. Canvas are invisible at run time when they do not contain images.

[quote=81876:@Daljit Summan]This was the very first todo item on a project I am starting and it failed, I spent 2 hours searching the web and trying all the examples but to no avail.

Has anyone got any suggestions, so far this hasn’t been a great experience.[/quote]

It is actually a very good first lesson in programming. You survived it and found your way here. Welcome :slight_smile:

  • Never take coding for granted. It baffles even the most seasoned developers.
  • When you feel like stuck, have a beer or a cup of tea, go for a walk, phone a friend, watch TV, and when you come back, chances are it will be easier
  • Don’t search the web when you have this forum

Contrary to application software, programming requires accepting ignorance as a chance to learn rather than as an unjust experience.

Thank you Michel - wise words.

I believe you may be talking about another example “ListBoxesDragAndDrop” which involves dragging between 2 list boxes on 1 dialog, the one I’ve listed above “ListBoxDragAndDrop” has 1 listbox which allows you to drop images files and such onto it, then double clicking an item in the listbox simply opens it up.

I agree 100% with your comments, but I really believe examples provided should work as intended - they are the first foray for a new user, if they fail, they start to kill any confidence in the product ( no matter how unfair that would seem ). They are the initial learning platform, running into a problem within a vendors actual example kinda sucks.

Thanks

[quote=81916:@Daljit Summan]Thank you Michel - wise words.

I believe you may be talking about another example “ListBoxesDragAndDrop” which involves dragging between 2 list boxes on 1 dialog, the one I’ve listed above “ListBoxDragAndDrop” has 1 listbox which allows you to drop images files and such onto it, then double clicking an item in the listbox simply opens it up.

I agree 100% with your comments, but I really believe examples provided should work as intended - they are the first foray for a new user, if they fail, they start to kill any confidence in the product ( no matter how unfair that would seem ). They are the initial learning platform, running into a problem within a vendors actual example kinda sucks.[/quote]

Allright. ListBoxDragAndDrop is interesting because it shows you how to open any kind of file, actually. The project does work perfectly on Mac, but follow Tim Hare example which works on both platforms and you will be fine.

Examples, in spite of all the testing I am sure Xojo put into them, remain like any piece of software, subject to bugs. This is another statement of importance : bug free does not exist. One of the most interesting challenge in programming is to go around bugs and limitations, to achieve ever higher goals. This forum is full of cooperative work where members achieve amazing results from often thinking out of the box. Like recently the post https://forum.xojo.com/6646-finding-string-matches where you can see how a DNA search has dramatically been improved that way.

Hang around and soon you will feel more comfortable. And never hesitate to ask :wink:

Thanks Michel

Please don’t misconstrue this as sarcasm or disrespect, nothings comes out well on the internet :slight_smile:

But if you read the very next reply after Tim Hare help suggestion I stated

I feel I may not have been clear, an example provided is kinda like a bit of reference ( almost analogous to a section in a textbook, or a tutorial video ) it is showing you how you use the “building blocks” to construct bigger and more elaborate programs - in which ( I agree ) bugs will always occur. If there is an error in a text book OR video it is corrected, because it will showing you something wrong.

I am finding this tricky because I have never used Xojo before, I don’t have the experience OR knowledge to apply various other lateral solutions in this product. If you gave me C# or objective-c (Xcode) I could construct a dozen hacks.

BUT if I have an example that when compiled runs perfectly in OSX but fails in Windows - out of the box - i.e. the actual learning material is potentially not up to scratch; well that needs addressing. Im afraid this cannot be cloaked under the statement ‘bug free does not exist’, it is an example with 12 lines of code, its needs to work it needs to be consistent, because it is attempting to guide you as to how this product works.

Anyway I will plug away - and put any findings here, in the hope it helps someone else out

If anyone can help I would appreciate it greatly, otherwise am dumping this and going native Xcode for OSX and .NET for for windows, where I know for sure things that I’m trying to achieve do work.

Thanks again Michel

Have to agree with Daljit.

In my opinion too often excuses are made for buggy code in the documentation and examples. That being said the situation has much improved since Paul was hired.

I happen to know .NET forums as well. Good luck if you find there the same kind of support as here :wink: And as far as documentation is concerned, Microsoft could take lessons from Xojo. Their Quick Start example to print from a Windows Store app is so badly written, the topic is all over their forum as something that simply does not work, neither is C, Java or .NET…

Grass is always greener on the other side of the fence, but that won’t spare you from doing your homework…

@Daljit Summan , After you change the code as told by Tim you have to add a filetypeset to the project:

Choose the Add button in the toolbar and select ‘File Type Set’,
then in the editor for the filetypeset choose the second button of the small toolbar just above the editor
then a list will popup with predefined filetypesets, ther choose the one called ‘special/any’

Run the program again and now it should work.

Dear Mr Kuiper :):):):slight_smile:

Thank you so much for your help!! That WORKED! I’ve wasted over 5 hours today !!! And I was no where NEAR that solution, in fact I don’t even understand why that works - but I shall research as much as I can to understand why.

Im still at odds as to why this small step was left out, it further asserts that this was indeed a error in the example rather then the perceived “bug” - it was probably never even run in Windows to check!

Thank you again.

Hopefully one day I can pass the karma on!

Be sure to create a Feedback case for the Windows bug in the example. We can’t fix it if we don’t know about it!

Sure thing.

[quote=81997:@Daljit Summan]Thank you so much for your help!! That WORKED! I’ve wasted over 5 hours today !!! And I was no where NEAR that solution, in fact I don’t even understand why that works - but I shall research as much as I can to understand why.

[/quote]

I gave you a solution that I tested on PC before posting it 2 hours ago…

[quote=81912:@Michel Bujardet]If you want to drop images, create a project with a canvas, and in the Open event, add what Tim Hare told you :

Me.AcceptFileDrop(“special/any;”)
In the DropObject event :

Me.Backdrop = Picture.Open(Obj.FolderItem)
[/quote]

Thanks Michel

That was not what I required, that was a hack to get a single picture arbitrarily dropped - I needed that example to work, because I needed to populate a listbox - which I have repeatedly stressed in this conversation.

I needed to drag and drop a multiple selection from finder/explorer (which I have just achieved) - why make it more convoluted when just that tiny step was required to get the example to work.

Anyway thanks for trying to help.

[quote=82014:@Daljit Summan]Thanks Michel

That was not what I required, that was a hack to get a single picture arbitrarily dropped - I needed that example to work, because I needed to populate a listbox - which I have repeatedly stressed in this conversation.

I needed to drag and drop a multiple selection from finder/explorer (which I have just achieved) - why make it more convoluted when just that tiny step was required to get the example to work.

Anyway thanks for trying to help.[/quote]

Why did you not,tell ? Anyway, congratulations.

Yea you’re right. Ive left the snippet of code here in case anyone else needs it.

Below shows code snippet to accept only SINGLE file drops into the listbox

If obj.FolderItemAvailable Then Me.AddRow(obj.FolderItem.Name) Me.RowTag(Me.LastIndex) = obj.FolderItem.NativePath End If

modifying it to

If obj.FolderItemAvailable Then Do Me.AddRow(obj.FolderItem.Name) Me.RowTag(Me.LastIndex) = obj.FolderItem.NativePath Loop Until Not obj.NextItem End If

allows a user to drop multiple files on the control, which registers them all - this is all done within the “DropObject” event of the “FileList” control, taking into consideration the steps pointed out by Andre Kuiper previously in this thread.

Thanks all.

Oops! I did test the code I posted, but I did not remove the filetypeset. I put in the filetypeset first and when that worked, I wanted to simplify it for you, so I changed it to the raw text. I assumed it would work with just the text, but as you found out, it didn’t. It worked for me, but only because the filetypeset was still in the project.

Glad you got it sorted out, and welcome aboard!

No worries !!

I don’t play blame games, I just like stuff to work or figure out how to make it work.

Thanks

Okay this is weird and I believe it is an OS issue not a Xojo issue. Though the example needs to updated to use a filetype set.

This works on my work machine but not my home machine. Both are Windows 7 64-bit and both up to date. Work machine is Professional and the home machine is Home Premium.

Me.AcceptFileDrop("special/any;")

This one works at home but not at work.

Me.AcceptFileDrop("special/any")

The only way to do it that works on both machines is to do as follows.

Me.AcceptFileDrop(FileTypes1.Any)

Looks like the FileType picks up constants from the OS.