Iâm wondering why the .Trim is necessary. Folderitem.NativePath is returned by Xojo. If the user were copying that string to paste elsewhere, and being perhaps loose in their selection, thatâs when you might want to trim it.
I did it to try and get rid of the space and return looking character. ultimately it does nothing to help and hurts nothing. Plus paths do not and should not end in whitespace so it is good to have.
Plus in this instance Xojo Folderitem.NativePath is returning bad characters so it might be needed!
I did a simple test project on Mac. For me (as expected), Folderitem.NativePath does not return whitespace on the end. As to my encoding idea, I would have been surprised if it were not returning UTF-8. Again, I was not surprised.
So yes, per your subject line, this is smelling like a Linux thing. I think I will play with that idea later, as I am sincerely interested in this and will certainly support any ticket you might open. My VM farm does include Mint 22, so I can start with that.
It Is only drag and drop that does this for me. All other instances of using folderitems in my history of using Xojo has not added these characters to the end.
Ah, but when I just sat down with it in the light of day, I found a mistake. The pushbutton code does not actually populate the Textfield. I had inadvertently removed 'TextField1.Text=myFolderItem.NativePath" while doing other editing (just before turning in.)
I wrote the example on my laptop last night, but now am at my desktop machine in the light of day. I already happened to have a Gentoo VM already up, and I can reproduce Paulâs issue myself. And now that I fixed the pushbutton code, it is clearly only drag and drop. I will try other distros, but I can tell you right now that itâs not just Mint. TextField test.zip (8.1 KB)
In the meantime, I found a workaround. Add this to the TextFieldâs TextChanged event handler. Paul, you were on the right track with the Trim, but doing it too soon.
Better than that, here is the revised project. I have removed the messageboxes, because that information (end of the string and encoding) proved not to be the issue.
I have since tested on Mint 22 myself and, as with Gentoo, have confirmed what Paul is getting. To try the workaround, un-comment the line in TextField1.TextChanged TextField test.zip (8.6 KB)
Iâll try this workaround tonight! Thanks for looking into it. If you guys havenât already comment on my issue so the people at Xojo know it isnât a 1 off instance.
Did your Gentoo system have Cinnamon installed as the DE? Or something else?
I have have two Gentoo VMs. One is stable (legacy BIOS) with XCFE. The one I originally tested was the cutting edge one (with EFI). That did in fact have Cinnamon.
Meanwhile, I appear to have solved the whole thingâWITHOUT a workaround. First, after confirming your issue on Mint and Gentoo, I got a separate one on Debian 12: drag and drop appended a âfile:///â prefix to the file name. That was weird, but maybe a clue.
The real clue game when I tried all of the Ubuntu distros (Ubunti? ), and drag and drop did not work AT ALL. Same with Arch. It was then that I realized that, in the TextFieldâs Opening event, I should have defined a file type for me.AcceptFileDrop. Mac didnât care, and the distros we were first looking at did what they did.
I did so (âtext/plainâ), and everything worked everywhere.
I have commented (and voted) on your issue, and added comments already. Now I have to do another one.
So yes, this yet-again revised sample project might help. Note that is has a FileTypesSet that gets referenced. I hope this helps. Weird, though that you did not see the problem I did on Ubuntu. TextField test.zip (8.8 KB)
Just out of curiosity, are you guys sure that the DropObject event is firing? I could see this being a function of the OS in that the field probably natively accepts text drops and a dragged FolderItem could be represented as text. It may just be a coincidence that it happens to show a native path.
Create a FileTypeGroup. In the IDE, there is a pulldown menu to select common ones. Choose âspecial/anyâ. After selection, you will notice that the extension field contains a wildcard *.
Then, in TextField.Opening, do
Me.AcceptFileDrop(FileTypeGroup1.Any)
You should now be able to drop any file, and of course the TextField only cares about the NativePath.
Offhand, I donât know of anything other the wildcard, if you wish to drop executables. Otherwise, populate the group with all relevant image types. Then you might do
Me.AcceptFileDrop(FileTypeGroup1.All)
PS: My one VM I hadnât yet tried was OpenSuse Leap 15.6. I retroactively ran the older, problematic build of my example on it and got the same âfile:///â prefix error as Debian. Both have Platinum desktops, which leads me to believe that Cinnamon was indeed the common factor for me on Mint and Gentoo.