Forum Discussion
Veeta
9 years agoVisitor
As far as I'm aware, you can't do it.
There's a compilation step when using Scene Graph XML that only happens once on startup. During that step is where you define a component and give it a name.
Then later you refer to this component by name.
What you've done with makeGridItem() is created a single instance of the Rectangle component type and given that instance a unique id of `gridItem`. MarkupGrid isn't looking at id's of object instances with itemComponentName, it's looking at the registry of defined component types.
There's a compilation step when using Scene Graph XML that only happens once on startup. During that step is where you define a component and give it a name.
<component name = "MyPoster" extends = "Poster" >
Then later you refer to this component by name.
m.grid = createObject("roSGNode","MarkupGrid")
m.grid.translation = "[100,100]"
m.grid.itemComponentName = "MyPoster"
What you've done with makeGridItem() is created a single instance of the Rectangle component type and given that instance a unique id of `gridItem`. MarkupGrid isn't looking at id's of object instances with itemComponentName, it's looking at the registry of defined component types.