slingxshot
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016
09:40 AM
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!
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!
8 REPLIES 8
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016
09:57 AM
Re: Accessing RowList component item element
This is one way;
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.
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
slingxshot
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016
11:30 AM
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
I need to some how to declare a variable outside then pass it over so it could increment...
Thanks
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016
11:55 AM
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"
That sounds like something you'd want to use a field and an observer for.
https://sdkdocs.roku.com/display/sdkdoc ... lueChanges
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
slingxshot
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016
12:29 PM
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
This way I have access everything within the same function without jumping around...?
Thank You
slingxshot
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016
02:05 PM
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.
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016
03:02 PM
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?
slingxshot
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016
08:32 PM
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
slingxshot
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2016
11:57 AM
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
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