Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
LRoszak
Visitor

Custom LabelList allowing setting of content in parentXML

I would like to extend LabelList (component let's name it MyListMenu) in a way that I can reuse some layout settings accros my channel, and specify it's content when used in xml.

What I would like to achieve is an option to specify something like this

<children>
<MyListMenu>
        <ContentNode id="menuContent" role="content">
          <ContentNode title="Play" />
          <ContentNode title="Settings" />
          <ContentNode title="Tutorial" />
        </ContentNode>
</MyListMenu>
</children>

I have a problem, that I can't find a way to define MyListMenu to handle setting of content and putting it in right place.
My xml for MyListMenu 
<component name="MyListMenu" extends="LabelList" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd"
  initialFocus="contentGroup"
>
  <interface>
    <field type="string" id="title" alias="titleLabel.text"/>
<!-- this didn't work, onContentChanged is never triggered-->
    <field type="node" id="content" onChange="onContentChanged" alwaysNotify="true"/>
  </interface>
  <script type="text/brightscript"
    uri="pkg:/components/View/Shared/MenuFrame/MenuFrame.brs" />
  <children >
    <Group translation="[100,200]" >
      <Rectangle width="680" height="400" color="0xFF0000FF" />
      <Rectangle translation="[15,50]" width="650" height="310" color="0xFFFFFFFF" />
      
      <Label id="titleLabel" width="680" horizAlign="center"/>
      <LabelList id="contentGroup" translation="[0,100]" >
        <!-- Here I would like to place content set from parent component -->
      </LabelList>
    </Group>
  </children>  
</component>

With code above ContentNode is displayed, but I cannot put it into LabelList with id "contentGroup", what is a proper approach to achieve this behavior?
0 Kudos
2 REPLIES 2
EnTerr
Roku Guru

Re: Custom LabelList allowing setting of content in parentXML

Ha, this is interesting! What you are trying to do is override in XML the .content field. Have you tried using the `role` karnapidasana?

Alternatively, you can do that in brightscript.
0 Kudos
LRoszak
Visitor

Re: Custom LabelList allowing setting of content in parentXML

Thanks, it at least got me somewhere, although not really in a clean way, but I can observe field content in my control, and then assign contentnode to a list inside. I also had to "forward" item selected events, but at least I got this working.

I wasn't able to use role to set content of my internal list directly, maybe some day we will find a proper yoga position for that.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.