Your Digital Media Has Never Looked So Good

 
lisakb140
Topic Author
Posts: 23
Joined: Tue Aug 14, 2018 8:18 am

Dynamically creating contentNodes for LabelList

Tue Oct 09, 2018 12:33 pm

I'm very new to Roku development, so please pardon my ignorance.

I have an array of strings and I'm trying to dynamically create a LabelList by looping through this array and setting each value as a ContentNode within the LabelList. However, I think I'm having a problem setting the LabelList as the "parent" of these contentNodes--ie, I'm essentially creating an empty LabelList.

My code is:



/* below, 'arr' is my associative array */
genreList = [i]createObject[/i]("RoSGNode","LabelList")
ContentNode_object = [i]createObject[/i]("RoSGNode","ContentNode")
   [b]for[/b] [b]each[/b] key [b]in[/b] arr
     ContentNode_child_object = ContentNode_object.createChild("ContentNode")
     ContentNode_child_object.field_name = arr[key]
   end for



Ideally, this would output the equivalent of this XML:

<LabelList
          id = "GenreList"
          translation = "[160,92]"
          itemSize = "[440,48]" >
 
          <ContentNode id = "genremenucontent" role = "content" >
           <ContentNode title = "sports" />
           <ContentNode title = "music" />
           <ContentNode title = "history" />
           <ContentNode title = "documentaries" />
    
          </ContentNode>

        </LabelList>


If I print LabelList, just to see what it is, I get the following, which makes me think the child ContentNode is not getting set correctly. 


<Component: roSGNode:LabelList> =
{
    color: -572662273
    focusedColor: 640034559
    focusedFont: <Component: roSGNode:Font>
    font: <Component: roSGNode:Font>
    textHorizAlign: "left"
    textVertAlign: "top"
    animateToItem: -1
    columnSpacings: <Component: roArray>
    columnWidths: <Component: roArray>
    content: <Component: roInvalid>
    currFocusColumn: -1
    currFocusFeedbackOpacity: 1
    currFocusRow: -1
    currFocusSection: -1
    drawFocusFeedback: true
    drawFocusFeedbackOnTop: false
    fadeFocusFeedbackWhenAutoScrolling: false
    fixedLayout: false
    focusBitmapBlendColor: -1
    focusBitmapUri: ""
    focusColumn: <Component: roArray>
    focusFootprintBitmapUri: ""
    focusFootprintBlendColor: -1
    focusRow: <Component: roArray>
    horizFocusAnimationStyle: "floatingfocus"
    horizFocusDirection: "none"
    itemClippingRect: <Component: roAssociativeArray>
    itemFocused: -1
    itemSelected: -1
    itemSize: <Component: roArray>
    itemSpacing: <Component: roArray>
    itemUnfocused: -1
    jumpToItem: -1
    numColumns: 1
    numRenderPasses: 3
    numRows: 12
    rowHeights: <Component: roArray>
    rowSpacings: <Component: roArray>
    scrollingStatus: false
    sectionDividerBitmapUri: ""
    sectionDividerFont: <Component: roSGNode:Font>
    sectionDividerHeight: 40
    sectionDividerLeftOffset: 0
    sectionDividerMinWidth: 117
    sectionDividerSpacing: 10
    sectionDividerTextColor: -572662273
    sectionDividerTopOffset: 0
    sectionDividerWidth: 0
    vertFocusAnimationStyle: "fixedfocuswrap"
    vertFocusDirection: "none"
    wrapDividerBitmapUri: ""
    wrapDividerHeight: 24
    wrapDividerLeftOffset: 0
    wrapDividerWidth: 0
    childRenderOrder: "last"
    clippingRect: <Component: roAssociativeArray>
    enableRenderTracking: true
    inheritParentOpacity: true
    inheritParentTransform: true
    muteAudioGuide: false
    opacity: 1
    renderPass: 0
    renderTracking: "none"
    rotation: 0
    scale: <Component: roArray>
    scaleRotateCenter: <Component: roArray>
    translation: <Component: roArray>
    visible: true
    change: <Component: roAssociativeArray>
    focusable: true
    focusedChild: <Component: roInvalid>
    id: ""
}


I found this post https://sdkdocs.roku.com/display/sdkdoc/Downloading+Server+Content on using a Task Node that seemed to be a similar case of what I need to do, but I think it's overcomplicated for my use case-- I don't need to download any information, as I already have this.

Any help or guidance would be greatly appreciated!

Who is online

Users browsing this forum: No registered users and 3 guests