Your Digital Media Has Never Looked So Good

 
Nethram
Topic Author
Posts: 9
Joined: Tue Oct 10, 2017 9:41 am

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

Wed Oct 11, 2017 11:59 pm

Hi,
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= m.top.findNode("trial")
m.trial.ObserveField("buttonSelected", "startsignup")

end sub

function startsignup()

m.firstpage.visible= false
m.subscription = createObject("roSGNode","Subscription")
m.top.appendChild(m.subscription)
m.subscription.setFocus(true)

end function

The created roSGnode has a button group with two buttons. 

Subscription.xml


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

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

</Group>

</children>

</component>


Subscription.brs

sub init()

m.buttongroup = m.top.findNode("submit")
m.buttongroup.buttons = [ "DECLINE", "ACCEPT" ]
m.buttongroup.ObserveField("buttonSelected","submit")

end sub


function submit()
if  m.buttongroup.buttonSelected = 1 then
m.accepted = createObject("roSGNode","Accepted")
m.top.appendChild(m.accepted)
m.accepted.setFocus(true)
else
?"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.
 
joetesta
Posts: 600
Joined: Wed Apr 20, 2011 11:48 am

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

Thu Oct 12, 2017 9:54 am

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



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

sub doSomething()
    'Remove child node'
    m.top.removeChild(m.trial)
end sub


when your button is clicked in the child, set the field to true in the child component,
function submit()
    m.top.watchThis = true
end function
aspiring
 
Nethram
Topic Author
Posts: 9
Joined: Tue Oct 10, 2017 9:41 am

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

Fri Oct 13, 2017 4:14 am

It worked ! Thank you so much.

Who is online

Users browsing this forum: No registered users and 1 guest