PDA

View Full Version : Windowlist is sorting the LAST entry added first



celestian
May 6th, 2020, 06:27
I recently had this popup on a windowlist. Here is the list of controls of "name"



'Combat Tracker'
'Party Sheet'
'Calendar'
'Colors'
'Lighting'
'Options'
'Modifiers'
'Effects'
'Tokens'
'Library'
'Modules'
'Audio'
'Kits'
'Encounters'
'Characters'
'Classes'
'Images'
'Items'
'Notes'
'NPCs'
'Quests'
'Races'
'Skills'
'Spells'
'Story'
'Tables'
'Parcels'


The window list looks something like this:



<template name="menu_records_list">
<windowlist>
<anchored >
<top offset="5" />
<left offset="5" />
<right offset="-5"/>
<bottom offset="-5" />
</anchored>
<frame name="darkbox" offset="5,5,5,5" />
<skipempty />
<noscroll />
<class>menu_record_item</class>
<sortby><control>name</control></sortby>
</windowlist>
</template>


And this is the "menu_record_item" windowclass.


<windowclass name="menu_record_item" >
<sheetdata>
<hs name="path" />
<hs name="record" />
<hn name="insert" />
<hs name="name" />
<label name="record_name">
<anchored height="20">
<top offset="0"/>
<left offset="4" />
<right offset="-4" />
</anchored>
<font>reference-b-light</font>
</label>
</sheetdata>
</windowclass>



So, as you can see from the windowlist template it should be sorting by "name" which is the first block of the post. This and others using the same template ALL sort the last entry on the windowlist FIRST in the windowlist. It looks like this.

https://i.imgur.com/P5tNdkH.png

I double checked that each menu_record_item had the "name" set and the getValue() returned the expected string... it did.

Runtime Notice: s'menu_record_item' | s'onClickDown' | s'window.name.getValue()' | s'Parcels'

Forcing an windowlist.applySort(true); doesn't seem to help either.

Anyone see an obvious reason why? I've two others and they both do the exact same thing... /boggle.

celestian
May 6th, 2020, 20:55
Forcing an windowlist.applySort(true); doesn't seem to help either.

So, I changed where I was running this and it now sorts properly. I debugged the sorting going on and it appears that adding a window to the list didn't update on the last entry added to the windowlist.

Adding this at the end of the loop that added everything resolved that. I'm not sure why it works this way but ... this works.