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?
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?)
Hey, that is some cool code Joe. ![]()
are you making fun of my code? ![]()
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.
Thanks, that was what I needed ![]()
no, not making fun of your code, just I hadn’t thought about doing it that way.
