Popup menu items not listed in order

  1. 2 weeks ago

    I have a popup menu which lists custom images, however they are not listed in order.
    The images are named like skin_001.png to skin_030.png. Instead of being listed in order, the last one listed is skin_008.png.

    This worked before but I'm not sure at what version of XOJO it quit working correctly.

    Thanks.

  2. Dave S

    Feb 9 San Diego, California USA

    they are listed in the order in which you added them to the menu.
    If you are just reading a file directory to get the names, they are not guaranteed to be returned in sorted order.

  3. Yeah I get them from a folder. Well I can live it.

    Oh well, thanks.

  4. Dave S

    Feb 9 San Diego, California USA

    just sort them first

  5. How do I sort them first ?

    I have a loop and add folderitem name to the popup menu.

  6. Dave S

    Feb 9 San Diego, California USA

    add them to an array... sort the array... add them to your menu

  7. Ah ok I see. thanks.

  8. Jürg O

    Feb 9 Pre-Release Testers, Xojo Pro
    Edited 2 weeks ago

    @Eric R I get them from a folder

    And I assume you've just looped over the FolderItem.Child's.

    @Eric R This worked before but I'm not sure at what version of XOJO it quit working correctly.

    What has changed is that Apple switched from the HFS filesystem to APFS.
    We used to get the FolderItem.Child's sorted alphabetically with HFS (even though this has never been guaranteed even then!).
    And with APFS, you don't get them sorted alphabetically (maybe sometimes, but hardly ever / I suspect it's some other "sort" we get). See also this Thread .

    I suspect that's it's such an APFS issue you've run into - it changes behavior even in "old applications".
    And @Dave S has given you the answer: If you want a list sorted, then do this (on your own). Don't expect a Framework to do that, unless it states explicitly that it does.

  9. Emile S

    Feb 9 Europe (France, Strasbourg)

    @Jürg O And with APFS, you don't get them sorted alphabetically

    There were a trick (30 years ago or so):

    Display the folder by list,
    Click view by name (into the a…z order),
    Select all,
    Move all into its original folder (move the files into its own folder),

    and the files appears now in the alphabetical order.

    Is this working in APFS ?

  10. Ah didn't know about that. I could switch it over to a listbox and use sort.. if I want to go to all that work. HA! ;-)

    Well thanks for all the help.

  11. Greg O

    Feb 10 Xojo Inc

    Or use SortWith..

    dim names() as String
    Dim items() as folderitem
    For i as integer = 1 to folder.count
        Items.Append folder.item(I)
        names.append(folder.item(I).name
    Next i
    
    names.sortWith items

    Then loop over items and put them in the pop up menu.

or Sign Up to reply!