Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 7

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

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

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=""
    <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"/>
  <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 -->

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
Level 11

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
Level 7

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