Multiple picture file types in OpenDialog

  1. 3 weeks ago

    Craig G

    Feb 4 Australia

    How can I display an open file dialog for multiple picture types using 2018R3 without having the user select the particular file type from a list in the dialog window..

    I am aware you can now use this in 2019R2 but is there an earlier equivalent?

      f = FolderItem.ShowOpenFileDialog( jpegType + pngType ) 

    @Craig Grech So you see the problem. It lists them separately.

    I have always understood. To clarify, your initial post implied that the API 2.0 code you posted would work. It does not.

    There's some information on how Windows handles the Filter property here: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.filedialog.filter?view=netframework-4.8 I'm not certain how you might pull it off in Xojo though.

  2. Emile S

    Feb 4 Europe (France, Strasbourg)
    Edited 3 weeks ago

    In the IDE, Insert Menu, add a New File Type.

    In that FileType, add as many as needed graphics file types, then use

    FileType1.All

    Edit: works since REALbasic 1.0.

  3. Sam R

    Feb 4 Pre-Release Testers, Xojo Pro, Third Party Store Hengchun, Pingtung, Taiwan
    Dim nod as new openDialog
    nod.filter = "public.image"
    
    Dim f as folderitem = nod.showmodal

    Will allow your user to select any kind of image file that the macOS can open.

  4. Tim P

    Feb 4 Pre-Release Testers, Xojo Pro Rochester, NY
    Edited 3 weeks ago

    @Craig G I am aware you can now use this in 2019R2 but is there an earlier equivalent?
    f = FolderItem.ShowOpenFileDialog( jpegType + pngType )

    Yes, you can do the same with Filter; but I don't think it circumvents the file type listing on the open dialog. Does 2019r2 / your method do something different? Can you humor me and post a screenshot if so?

    dim tod as new OpenDialog
    tod.Filter = pngType + jpgType

    (assuming you've made pngType and jpgType)

    @Sam Rowlands Will allow your user to select any kind of image file that the macOS can open.

    The "user must select the type first" is a user experience failure of Windows. ;)

  5. Craig G

    Feb 5 Australia
    Edited 3 weeks ago

    I have at least four image file types as I can't seem to combine them into one filetype.
    So the user has to click the drop down on the dialog to display the type of image to add. I feel many users will not take this step and presume their images aren't compatible.

        dlg=New OpenDialog
        dlg.Title= "Select a picture file"
        dlg.Filter=imageFiles.all
        f=dlg.ShowModal

    -image-

  6. Emile S

    Feb 5 Europe (France, Strasbourg)
    Edited 3 weeks ago

    @Craig G imageFiles.all

    Isn’t it what I wrote earlier ?

    Click below to download the original image:
    link text

  7. Craig G

    Feb 5 Australia

    @Emile S Isn’t it what I wrote earlier ?

    Click below to download the original image:
    link text

    Yes it is Emile and that's why I included a picture to show you why that isn't suitable ie. it produces a LIST of file types.

    I want it ALL image file types to appear without having the use select individual types from a list ie. to display them as they do in 2019R2 using FolderItem.ShowOpenFileDialog( jpegType + pngType )
    See second example on page [url=http://docs.xojo.com/FolderItem.ShowOpenFileDialog [/url] showing how ShowOpenFileDialog can combine several FileTypes in the way the example shows.

  8. Tim P

    Feb 5 Pre-Release Testers, Xojo Pro Rochester, NY

    @Craig G I have at least four image file types as I can't seem to combine them into one filetype.
    So the user has to click the drop down on the dialog to display the type of image to add. I feel many users will not take this step and presume their images aren't compatible.

    Right, I understand this, but how do you expect the API 2.0 code you posted to behave any different?

    @Craig G] See second example on page [url=http://docs.xojo.com/FolderItem.ShowOpenFileDialog [/url] showing how ShowOpenFileDialog can combine several FileTypes in the way the example shows.

    I've just tested and I get the exact same list as if there were multiple types supplied to the filter property.

  9. Craig G

    Feb 5 Australia

    @Tim P I've just tested and I get the exact same list as if there were multiple types supplied to the filter property.

    So you see the problem. It lists them separately.
    I want all the different image file types I have created to be available together.
    Is this possible without using "*.*" and getting every file?

  10. Tim P

    Feb 5 Pre-Release Testers, Xojo Pro Answer Rochester, NY

    @Craig Grech So you see the problem. It lists them separately.

    I have always understood. To clarify, your initial post implied that the API 2.0 code you posted would work. It does not.

    There's some information on how Windows handles the Filter property here: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.filedialog.filter?view=netframework-4.8 I'm not certain how you might pull it off in Xojo though.

  11. Craig G

    Feb 5 Australia
    Edited 3 weeks ago

    @Tim P I have always understood. To clarify, your initial post implied that the API 2.0 code you posted would work. It does not.

    My apologies Tim.
    I use 2018R3 so wasn't aware that it produced the same result as 2019R2.
    I may be better using a file type for all files (*.*) and pop up a message if they choose something that isn't a compatible image file. They really don't realize there is a drop down list.

  12. Tim P

    Feb 5 Pre-Release Testers, Xojo Pro Rochester, NY

    Try Sam's public.image filter first. I think it's a macOS thing, but wouldn't it be awesome if it worked?

or Sign Up to reply!