Sorting listbox entries via Array/Json load, doesnt work

0 favourites
  • 2 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • Hi,

    I need to add, remove names in list box. The names need to be sorted, no more than 20 names right now. I tried to us Array for sorting and then load the sorted values into the listbox, but it didnt work. Any idea why not?

    Here is the essential code:

    ButtonAdd onClick & not TextBox is ""

    Array Push back TextBox.Text on X axis

    Array Sort X axis

    List set from JSON string Array.AsJSON

    thanks,

    Daniel

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi,

    In the meantime I wasn't able to understand why the json based code doesn't work, but was able to solve the sorting the following way:

    ButtonAdd onClick & not TextBox is ""

    • Array Push back TextBox.Text on X axis
    • Array Sort X axis

    -- Array For each X element

    --- Array Current value =/= 0 List Add Item Array.CurValue

    Also in the Array property menu the dimension of the array has to be set to 1 on each dimension: Width=1, Height=1, Depth=1 otherwise this doesnt work.

    Note that I had to set the condition Array Current value =/= 0, otherwise an empty line would appear in the listbox. This is because the array is prefilled with a first value of zero, because i had to set Width to 1, for the array to receive add values.

    It works, but since i am always interested in learning new techniques, any ideas how to do this better would be much appreciated.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)