Roku Developer Program

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

How to access RowList elements?

Hello, I have a RowList, which renders some elements, each containing a Poster and a Label node. When an item has focus, I want to change the color of its label. How can I achieve that?
0 Kudos
5 Replies
joetesta
Level 10

Re: How to access RowList elements?

you could do something like this:

In the component definition of your rowlist's itemComponentName item add:

<field id="focusPercent" type="float" onChange="onItemFocusChange"/>


And in the brs code of your rowlist's itemComponentName item put

sub onItemFocusChange()
    if m.top.focusPercent <> invalid and m.top.focusPercent = 0 and m.top.getchild(0) <> invalid
        m.top.getchild(0).getchild(1).color = "0xffffffff" 
    else if m.top.getchild(0) <> invalid
        m.top.getchild(0).getchild(1).color = "0xff0000ff"
    end if
end sub



In the above, m.top.getchild(0) references the item in the row, and m.top.getchild(0).getchild(1) references the title of that item.
(Although testing it, it's not the smoothest, there may be a better way but this may get you on the right track?)
aspiring
0 Kudos
destruk
Level 10

Re: How to access RowList elements?

Hey, that is some cool code Joe. Smiley Happy
0 Kudos
joetesta
Level 10

Re: How to access RowList elements?

are you making fun of my code?  Smiley LOL
I found switching in `< 1` instead of '= 0' makes it a little smoother (only one label has the highlight color at a time)
I'm sure there's a way to do it so they transition simultaneously. 
I tried using the 'rowItemFocused' field of the rowlist itself, but then the rowlist doesn't have access to the actual visible node defined under itemComponentName.  I think using this field would smooth it out, believe it could be done with an observer set when the rowlist items are created.
aspiring
0 Kudos
rado_ap
Level 7

Re: How to access RowList elements?

Thanks, that was what I needed Smiley Happy
0 Kudos
destruk
Level 10

Re: How to access RowList elements?

no, not making fun of your code, just I hadn't thought about doing it that way.
0 Kudos