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: 
brybott
Visitor

Graph Scene Custom Components Issue

Hello,

I know this is a shot in the dark, but I guess I should try anyways.

I'm trying to programatically create a custom graph scene component that extends the Group component. Something like this:
<component name="myComponent" extends="Group">

I want to create it after an event occurs. However, when I do the following:

myComponentNode = CreateObject("roSGNode", "myComponent")


myComponent is invalid.

In the same piece of code, I'm able to successfully create a node if I substitute the above with:

myComponentNode = CreateObject("roSGNode", "Group")


Additionally, if I create a node based on myComponent elsewhere in the code, it works perfectly fine. So the question is, is there a situation that would prevent a custom component from being able to create a node?
0 Kudos
6 REPLIES 6
TheEndless
Channel Surfer

Re: Graph Scene Custom Components Issue

Not sure what could be causing that, especially if creating a Group in the same place works, but is there any reason you couldn't create the component in the XML and set visible to false, then make it visible after your event?
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
brybott
Visitor

Re: Graph Scene Custom Components Issue

After more experimentation, I've deduced that it is not possible to create custom components in observeField() callback functions.
Additionally as is mentioned in this post, it's not possible to create custom components from within the onKeyEvent function.

Unfortunately, the way I've set things up, I was really counting on the ability to create a custom component programatically upon recognizing an event. This is going to take some serious refactoring now...
0 Kudos
TheEndless
Channel Surfer

Re: Graph Scene Custom Components Issue

"brybott" wrote:
After more experimentation, I've deduced that it is not possible to create custom components in observeField() callback functions.

I'm not seeing that at all. I'm able to create and show custom (and non-custom) components in observeField callbacks. Are you making sure to keep the component in scope? If you're just creating it in a variable local to the function, it'll get disposed as soon as you exit the function.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
brybott
Visitor

Re: Graph Scene Custom Components Issue

"TheEndless" wrote:
Are you making sure to keep the component in scope? If you're just creating it in a variable local to the function, it'll get disposed as soon as you exit the function.


The issue I'm having is that it won't even create the custom component, let alone give the opportunity to add it to the scene.
When called from an observeField callback,


CreateObject("roSGNode", "MyCustomComponent")

returns Invalid.
When called in a non event based way (in init(), for instance), it creates the component as expected.

I have a simple test app that demonstrates the issue and that I'd be happy to share if anyone is interested in investigating further.
0 Kudos
TheEndless
Channel Surfer

Re: Graph Scene Custom Components Issue

"brybott" wrote:
I have a simple test app that demonstrates the issue and that I'd be happy to share if anyone is interested in investigating further.

Please do share the test app. I'd like to take a look.

I can say that I'm working on a project right now where I dynamically create custom components in response to itemSelected changes in a RowList without issue. I am developing on 7.1, though, so if you're still on 7.0, it's possible it's something they fixed.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
brybott
Visitor

Re: Graph Scene Custom Components Issue

Ok, so I think I realized the issue.

I was changing the observable field after recognizing a keypress. And as other people have noticed, creating custom components in the onKeyEvent function doesn't work. Apparently creating custom components from within other functions that are set in motion by the onKeyEvent function also doesn't work.

When creating a custom component in the observeField() callback, and updating the observable field from within an onKeyEvent function, the component was created as expected.

That being said, as I was writing this post, I checked if today was the magic day I could update to 7.1, and lo and behold it was. So, after updating, creating custom components in the onKeyEvent function worked like a charm!

Thanks for your help The Endless, seems like I just had to be patient and wait for my update.
0 Kudos