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

Accessing RowList component item element

Hello,

In the RowList I am trying to access the itemComponentName specific focused item. I am creating Poster elements inside. I need to access to Poster and do something like this:

 m.videoElm = m.Poster.createChild("Video")
 m.videoElm.width = "400"
 m.VideoElm.height = "280"

The problem I can't do onFocus inside itemComponent xml file, I need to access the Poster element from outside. How would I do that?

Thank You!
0 Kudos
8 REPLIES 8
joetesta
Roku Guru

Re: Accessing RowList component item element

This is one way;

Poster_element_from_outside = m.top.findNode("PosterElementID")


https://sdkdocs.roku.com/display/sdkdoc/ifSGNodeDict#ifSGNodeDict-findNode(nameasString)asObject

Obviously you need to switch in the actual ID of your poster element (and assign an ID if it doesn't have one yet), and probably make a better (shorter) var name for the left side of the equation.
aspiring
0 Kudos
slingxshot
Streaming Star

Re: Accessing RowList component item element

I am guessing the id of that Poster id element needs to be unique. How would I assign a unique value inside the custom.xml file? 

I need to some how to declare a variable outside then pass it over so it could increment...

Thanks
0 Kudos
joetesta
Roku Guru

Re: Accessing RowList component item element

You can set it in the component definition in the XML;
https://sdkdocs.roku.com/display/sdkdoc/XML+Components
<Gizmo id="MyGizmo" />

Or after the fact in your brightscript code;

mything = CreateObject("roSGNode", "Poster")
mything.id = "mything_id"

I need to some how to declare a variable outside then pass it over so it could increment...


That sounds like something you'd want to use a field and an observer for.
https://sdkdocs.roku.com/display/sdkdoc ... lueChanges
aspiring
0 Kudos
slingxshot
Streaming Star

Re: Accessing RowList component item element

It sounds like I need to create the RowList component dynamically (using script) instead of using an XML file. Is there an example how this be done?

This way I have access everything within the same function without jumping around...?

Thank You
0 Kudos
slingxshot
Streaming Star

Re: Accessing RowList component item element

"joetesta" wrote:
This is one way;

Poster_element_from_outside = m.top.findNode("PosterElementID")


https://sdkdocs.roku.com/display/sdkdoc/ifSGNodeDict#ifSGNodeDict-findNode(nameasString)asObject

Obviously you need to switch in the actual ID of your poster element (and assign an ID if it doesn't have one yet), and probably make a better (shorter) var name for the left side of the equation.

This didn't work. I assigned the Poster a unique id value. I verified its assigned within component xml file. 
But when I try to access it onFocus event 
Poster = m.top.findNode("Poster1")
gives me "invalid", any other solutions.
0 Kudos
EnTerr
Roku Guru

Re: Accessing RowList component item element

"slingxshot" wrote:
Poster = m.top.findNode("Poster1")
gives me "invalid"

Sounds like the element with id "Poster1" is just not attached to the current hierarchy? Check what's `m` and `m.top` in that context, see if the poster is hanging where it should be in the tree. Also case-sensitivity (i don't think it is) of ID?
0 Kudos
slingxshot
Streaming Star

Re: Accessing RowList component item element

"EnTerr" wrote:
"slingxshot" wrote:
Poster = m.top.findNode("Poster1")
gives me "invalid"

Sounds like the element with id "Poster1" is just not attached to the current hierarchy? Check what's `m` and `m.top` in that context, see if the poster is hanging where it should be in the tree. Also case-sensitivity (i don't think it is) of ID?

i am using this example as a guide
https://github.com/rokudev/hero-grid-channel
Everything displays and functions correctly thought.

I believe m.top is HeroScreen .... is that wrong.. how else would I access RowList Poster... from HeroScreen component
0 Kudos
slingxshot
Streaming Star

Re: Accessing RowList component item element

So I was doing some experiments...

So basically the component for the RowList is just a loop. So when I create the Post Element with a specific id, doesn't it just get overwritten over and over... it seems like it is a temporary item...

correct me if I am wrong 
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.