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: 
WSJTim
Binge Watcher

Initializing children of a custom component

Jump to solution

I'm writing a custom component that extends LayoutGroup and I'd like to set up event observers on children. When my init() sub gets called, m.top has no children yet so I can't access any yet. In later methods (like "onKeyEvent") I can see the children there but obviously I don't want to set everything up multiple times.

Any help would be appreciated!

tim

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
WSJTim
Binge Watcher

Re: Initializing children of a custom component

Jump to solution

Ok, I got this working. If anyone else is curious, it looks like the correct solution is to observe the "change" property...

https://developer.roku.com/docs/references/scenegraph/abstract-nodes/node.md

I get an "add" operation when each child is added. Cool!

View solution in original post

0 Kudos
2 REPLIES 2
WSJTim
Binge Watcher

Re: Initializing children of a custom component

Jump to solution

Ok, this might not have been clear. These are children not specified by my component directly. Once again, similar to a LayoutGroup. For example:

<MyComponent>
    <Button .../>
    <Label .../>
    <Button .../>
</MyComponent>
0 Kudos
WSJTim
Binge Watcher

Re: Initializing children of a custom component

Jump to solution

Ok, I got this working. If anyone else is curious, it looks like the correct solution is to observe the "change" property...

https://developer.roku.com/docs/references/scenegraph/abstract-nodes/node.md

I get an "add" operation when each child is added. Cool!

0 Kudos
Community is Temporarily in Read-Only Mode!

We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. You will not be able to log in or post new comments or kudos during this time. Read more here.

Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 12 and you may notice reduced functionality. In the meantime, for additional assistance, visit our Support Site.

Thanks for your patience — we’re excited to share what’s next!