Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 7

Roku scene graph - How to send data from roSGnode to parent.

In my app I have a trial button,a signin button and a signup button in scene that created from "main.brs" .When trial button clicked , it will create roSGnode as follows.

sub init
m.trial.ObserveField("buttonSelected", "startsignup")

end sub

function startsignup()

m.firstpage.visible= false
m.subscription = createObject("roSGNode","Subscription")

end function

The created roSGnode has a button group with two buttons. 


<component name = "Subscription" extends = "Group" initialFocus="fullcontent">
<children >

<ButtonGroup id="submit" 
layoutDirection = "horiz"
translation = "[ 500,600]"





sub init()

m.buttongroup ="submit")
m.buttongroup.buttons = [ "DECLINE", "ACCEPT" ]

end sub

function submit()
if  m.buttongroup.buttonSelected = 1 then
m.accepted = createObject("roSGNode","Accepted")
?"Back to home scene"
end if
end function

I want to send a notification from the child to home scene and  remove the child when user clicks the "cancel" button.
please help me to solve this problem.
0 Kudos
2 Replies
Level 11

Re: Roku scene graph - How to send data from roSGnode to parent.

add an interface field to your child (trial) node.
    <field id="watchThis" type="boolean" value="false"/>

observe the interface field from the parent node
m.trial.observeField("watchThis", "doSomething")

sub doSomething()
    'Remove child node'
end sub

when your button is clicked in the child, set the field to true in the child component,
function submit() = true
end function
0 Kudos
Level 7

Re: Roku scene graph - How to send data from roSGnode to parent.

It worked ! Thank you so much.
0 Kudos