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: 
rado_ap
Visitor

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 5
joetesta
Roku Guru

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
Streaming Star

Re: How to access RowList elements?

Hey, that is some cool code Joe. 🙂
0 Kudos
joetesta
Roku Guru

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
Visitor

Re: How to access RowList elements?

Thanks, that was what I needed 🙂
0 Kudos
destruk
Streaming Star

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