DropObject not working

Just trying to start out simple with Drop Object. Read what I could online but haven’t been able to make it work.

So, when a users drags a file onto a Bevel Button, I want to a message box the native path to the file.

Here’s what I’ve got in the Open EvenHandler for the BevelButton

[code]dim msifile as new filetype

msifile.Extensions = “msi”

me.AcceptFileDrop FileType(msifile)[/code]

And here’s what I have the the Drop Object Event Handler

[code]if obj.FolderItemAvailable then
dim f as FolderItem = obj.FolderItem

dim path as String = f.NativePath

MsgBox path
end[/code]

Not only does that message box not come up, but I get a the circle with the line through it on the drag, showing it’s not accepting the file. And yes, the file ends with .msi extension.

Thoughts?

your filetype goes out of scope at the end of the open handler
and that will make this not work

[quote=474843:@Norman Palardy]you filetype goes out of scope at the end of the open handler
and that will make this not work[/quote]

Meaning?

Make the filetype a property of the window or app so it keeps a reference to it

Use Insert… Add a File Type (in the MenuBar). Sorry, I do not found the entry in the LR.

and feed the window.

meaning that you get the exact effect you are seeing
your file type variable needs to exist somewhere else that it will not get cleaned up at the end of the open event
like as a property on the window itself

At last, I think I get the right page:

User’s Guide - File Type Sets …

[quote=474860:@Emile Schwarz]At last, I think I get the right page:

User’s Guide - File Type Sets …[/quote]

Yeah, I already read that. Didn’t help.

OK, so I setup a property under the window called misfile. I set it to a “type” FyleType.

I set the extension to msi in the code window.

Now, when I run the app and open that window, I get a nilobjectexception on the code me.AcceptFileDrop FileType(msifile) in the open event handler.

Read it once more. Not only this help (once you understand it), but this is the way to go.

A File Type Set defined this way is availabela all round the project, not only here or there; it never goes out of scope.

Now, if you prefer to do things differently, that is your software.

Good luck.

[quote=474867:@Emile Schwarz]Read it once more. Not only this help (once you understand it), but this is the way to go.

A File Type Set defined this way is availabela all round the project, not only here or there; it never goes out of scope.

Now, if you prefer to do things differently, that is your software.

Good luck.[/quote]

It’s not helping in the example I’m discussing.

dim msifile as new filetype

Put this where you need it, not elsewhere. So it will be available when you need it and goes out of scope as soon as you stop need it.

But if you need it at different places in your project…

Do you have a FileType Set in the project item list? If not, add one as Emile said earlier. In the FileType Set, set up an entry with the name ‘MSI’, the Display Name ‘MSI’, and the extension ‘.msi’ (don’t forget the dot if you are on Windows).

In the Open event for the Bevelbutton, add the code

Me.AcceptFileDrop ("MSI")

Your code in the DropObject event should be okay.

[code]if obj.FolderItemAvailable then
dim f as FolderItem = obj.FolderItem

dim path as String = f.NativePath

MsgBox path
end[/code]

So, when you say “Name” MSI, do you mean the text field under name, or the ID name off to the right? Depending on which one I name MSI, I get two very different error.

If the text field name is set to MSI, I get am “Item does not exist” error for “Me.AcceptFileDrop (“MSI”)”

If the ID name is set to MSI I get "CREATE.BevelButton1.Open, line 2
Expected a value of type No Type, but found a static namespace reference to No Type.
me.AcceptFileDrop FileType(MSI)
"

[quote=474871:@Dale Arends]Do you have a FileType Set in the project item list? If not, add one as Emile said earlier. In the FileType Set, set up an entry with the name ‘MSI’, the Display Name ‘MSI’, and the extension ‘.msi’ (don’t forget the dot if you are on Windows).

In the Open event for the Bevelbutton, add the code

Me.AcceptFileDrop ("MSI")

Your code in the DropObject event should be okay.

[code]if obj.FolderItemAvailable then
dim f as FolderItem = obj.FolderItem

dim path as String = f.NativePath

MsgBox path
end[/code][/quote]

I got it. Bad typing on my part. Your example worked.

Thank you Dale and everyone!