sjbarag / brs

An interpreter for the BrightScript language that runs on non-Roku platforms.
MIT License
113 stars 43 forks source link

Custom Node that extends from Group can't instantiate child nodes? #485

Closed adheus closed 4 years ago

adheus commented 4 years ago

I have a MaskGroup node(mock) that extends from Group:

<component name="MaskGroup" extends="Group">
    <interface>
        <field id="masksize" type="array" />
        <field id="maskOffset" type="array" />
    </interface>
    <script type="text/brightscript" uri="MaskGroup.brs" />
</component>

But when appending it to a another node:

SomeNode.xml

<component name="SomeNode" extends="Group">
    <script type="text/brightscript" uri="SomeNode.brs" />
    <children>
        <MaskGroup id="maskGroup">
           <Rectangle id="rect1" />
        </MaskGroup>
        <Rectangle id="rect2" />
    </children>

SomeNode.brs :

sub init()
    m.rect1 = m.top.findNode("rect1")
    m.rect2 = m.top.findNode("rect2")
    ?"rect1"; m.rect1
    ?"rect2:"; m.rect2
end sub

It seems to not find rect1. Output from code above:

rect1 invalid
rect2: <Component: roSGNode:Rectangle> =
{
    change: <Component: roAssociativeArray>
    focusable: false
    focusedchild: invalid
    id: rect2
    visible: true
    opacity: 1
    translation: <Component: roArray>
    rotation: 0
    scale: <Component: roArray>
    scalerotatecenter: <Component: roArray>
    childrenderorder: renderLast
    inheritparenttransform: true
    inheritparentopacity: true
    clippingrect: <Component: roArray>
    renderpass: 0
    muteaudioguide: false
    enablerendertracking: false
    rendertracking: disabled
    width: 0
    height: 0
    color: 0xFFFFFFFF
    blendingenabled: true
}

Also, if I do maskGroup.getChildCount(), it returns 0.

lkipke commented 4 years ago

Great find! Looks like we're not instantiating more than one level deep of children (code here). Thanks for calling it out, should hopefully be a pretty quick fix.