on macOS / 2024r4.2 / Sequoia 15.4:
Var jpegType As New FileType
jpegType.Name = "image/jpeg"
jpegType.Extensions = "jpg;jpeg"
dropped .jpg files are rejected.
If I keep only “jpg” in Extensions, the same image is read.
If I keep only “jpeg” in Extensions, the same image is rejected; its extension is .jpg.
Must I add a second FileType for JPEG ?
PS: tested with 2025r1 with the same behavior.
Make a small sample showing the problem and share here with instructions. Add all necessary things in a zip package, including a jpeg used in the test sample.
Here you are:
FileType_Bug.zip (2.9 MB)
Here, fixed.
FileTypeDrop.zip (325.3 KB)
Several small mistakes. But one you probably would miss. Your filetype objects going out of scope and Xojo’s internal routines needing them after the initialization but they were released… so I made them static and always in memory. Negligible memory footprint for that case.
OK, Thank You.
But how do you explain that (in DropObject [read far below]):
Var jpegType As New FileType
jpegType.Name = "image/jpeg"
jpegType.Extensions = "jpg"
Works fine ?
And:
Var jpegType As New FileType
jpegType.Name = "image/jpeg"
jpegType.Extensions = "jpeg"
PS: until sometimes in the past, if you do not check and exclude unwanted file types in DropObject does not worked; your shared code leads to crash when dropping a text fille (not svg image of course / macOS). To be sure, I dropped folders and other non defined file types to the window and they were rejected !
At last, and curiosity oblige, I replaced Static with Var, and the drop occured as expected.
The important thing to remember is that check the file type in DropObject is no more mandatory.
Thank You.
Well, when I tested it using windows and Xojo 2024r4.2 it wasn’t, so I perceived that that was the cause and made it static to solve it.
All depends on the context, for your supplied request the way I handled it with limited acceptance it was enough.
I recall Greg telling that (the FileType going out of scope), but I forgot the context. (I recall when I read your answer, of course).
For WIndows, Extensions must have the leading dot.
Nope. The sample I provided was tested under windows.