Your Digital Media Has Never Looked So Good

 
rado_ap
Topic Author
Posts: 3
Joined: Tue Jun 20, 2017 4:55 am

How to access RowList elements?

Mon Jul 17, 2017 5:16 am

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?
 
joetesta
Posts: 513
Joined: Wed Apr 20, 2011 11:48 am

Re: How to access RowList elements?

Mon Jul 17, 2017 11:56 am

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
 
User avatar
destruk
Posts: 2483
Joined: Sat Dec 18, 2010 4:58 pm

Re: How to access RowList elements?

Mon Jul 17, 2017 2:33 pm

Hey, that is some cool code Joe. :)
 
joetesta
Posts: 513
Joined: Wed Apr 20, 2011 11:48 am

Re: How to access RowList elements?

Mon Jul 17, 2017 6:18 pm

are you making fun of my code?  :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
 
rado_ap
Topic Author
Posts: 3
Joined: Tue Jun 20, 2017 4:55 am

Re: How to access RowList elements?

Mon Jul 17, 2017 11:43 pm

Thanks, that was what I needed :)
 
User avatar
destruk
Posts: 2483
Joined: Sat Dec 18, 2010 4:58 pm

Re: How to access RowList elements?

Tue Jul 18, 2017 12:27 pm

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

Who is online

Users browsing this forum: No registered users and 1 guest