PDA

View Full Version : How do you determine index number of a widget?


jbuszkie
01-13-2006, 02:45 PM
I'm looking through the widget API's and I don't see anything that will return the widget position number.

say you have

a
b
c
d
e
f
g
h
i

and I want to insert a widget between G and H. I can search for A and make a child widget for it and specify 0 for the index.. but I want it between G and H. I can search for G... but how do I get it's index number so I can bump the index by one and insert my widget there using InsertWidgetChild?

Am I going to have to GetAllChildren and seach until I find G and remember how many I went through? That seems like a pain. Am I missing an API that will do this?

Thanks,

Jim "In STVi hell"

nielm
01-13-2006, 03:00 PM
I'm looking through the widget API's and I don't see anything that will return the widget position number.

a
b
c
d
e
f
g
h
i

From memory:

Assume that you have found and have assigned widgets a,g and the new widget z to varibles...


get position of g in list of a's children:
pos=FindElementIndex(GetWidgetChildren(a),g)
the insert the new widget as a child
InsertWidgetChild(a,z,pos+1)


The thing you were missing is that the general API list modification functions (FilterBy*, GetElement, and FindElementIndex) can be used with widget lists :)

Good luck with the stvi :) And I agree with you abotu STVi hell, but is better than manually merging all changes at each version update :)

jbuszkie
01-13-2006, 03:12 PM
get position of g in list of a's children:
pos=FindElementIndex(GetWidgetChildren(a),g)
the insert the new widget as a child
InsertWidgetChild(a,z,pos+1)


The thing you were missing is that the general API list modification functions (FilterBy*, GetElement, and FindElementIndex) can be used with widget lists :)

Yeah.. That will work.. Duh! I forgot about the FindElementIndex! (well I haven't had to use it yet so I didn't think to look for it!!) Stupid me!


Good luck with the stvi :) And I agree with you abotu STVi hell, but is better than manually merging all changes at each version update :)
Is it though??? :)

Thanks a bunch! :clap:

Jim