Can't drag files into ListBox in Windows

Ask and ye shall receive. :slight_smile:

Creepy but uh thanks I guess.

Just to report that… IT WORKED!!!
Thank you.

2 Likes

Something about this thread had me wondering since I’ve never had a problem with dropping files on Listboxes, or any other control, that needed them. So, I tried a few tests with various FileTypes configurations. Basically, what I found was that if there is anything in the Extensions field it needs to be “recognizable” to the OS. So using *.* seems to be seen as ‘any and all files, including folders’. The same seems to be if there is nothing in the extensions field. So leaving that blank works the same as *.* apparently. Exactly why .* doesn’t work I don’t know but it sure doesn’t.

Of course, putting the dot in with extensions enables the filtering (and on Windows, the dot is necessary).

Now what I would like to see is a form where I could specify ‘any and all files but not folders of any kind’ .

Just for completeness, I tested it on Windows 10 with Xojo 2020r2.1 (since I can’t migrate to anything later until/unless they get the StyledTextPrinter issue fixed.)

1 Like

To reject Directories, in Window1.DropObject Event, use:

If Obj.FolderItem.Directory Then
Return
End If

for example.

Not tested, written on the web browser.

Yeah, Emile, that’s what I generally have to do but it doesn’t give the visual feedback while dragging since the “filtering” doesn’t take place until the actual drop.

Put it on the DragEnter, see RectControl.DragEnter - Xojo Documentation, the very last line of that page, remove the Not (ps. might want to tweak the code for multiple DragItems)

That is what we have to do on macOS…

The lack of visual indication (and, more generally, a way to prevent the OS to think the drag would be allowed when the user release the mouse) is something you shouldn’t just work-around.

1 Like