Type organisation *sigh*

Blitz3D Forums/Blitz3D Beginners Area/Type organisation *sigh*

Hey peeps!

Need a little beginners help here :)

Ive got a small problem organising my gadgets. I have previously used a field "Order" which actually slightly changes the z position of the gadgets in 3d to position them first/last/wherever, what i need to do, is organise the type list in such a way that the first to be drawn is the first in the list...

Ive tried using before/after first/last but im getting no luck.

The reason i need to do this is because in my previous technique, everything apart from the front gadget would lose its order. using this technique, if i click on level, then file, then camera, they will apear in that order rather than when i click on camera, file going to the back.

So,

How can i order my type list? is there a bug or am i just doing it wrong?
Heres some code im using:


Type ui_gadget
Field iterated=0
Field name$
Field childcount
Field child.ui_gadget[1024]
Field ID
Field title$
Field mesh
Field surface
Field parent
Field Pickable
Field x,y,width,height
Field Globalx,Globaly
Field Txt$
Field Ret$
Field Texture
Field textureframes
Field Togglemode
Field Toggle
Field Order#
Field draworder#
Field minx,miny,maxx,maxy
Field autohide
End Type

Function bringtofront(gadgetid)

Local frontgadget.ui_gadget=gadgetfromID(findparent(gadgetID))
Local gadget.ui_gadget
Local gadget2.ui_gadget
Local Lastgadget.ui_gadget=Last ui_gadget
Local count=1,cc,c2,ocnt,cnt=1

Insert frontgadget After Last ui_gadget ;insert the gadget at the end of the list!????

If frontgadget<>Last ui_gadget Then RuntimeError "poo" ;test if its not working, seems to be....

cc=frontgadget\childcount

For c2=1 To cc  ;iterate and bring children to front also
Insert frontgadget\child[c2] After Last ui_gadget ;Place child last
;(forcing the previous last position back one? is that how it works?)
Next

;Now iterate through the list and give them all an order...
For gadget=Each ui_gadget
GADGET\ITERATED=0
gadget\draworder=cnt
gadget\order=cnt
updategadget gadget
cnt=cnt+1
Next
.....