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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Close Child Scene

I've attached my code. Pretty straightforward I've read previous articles stating that I can only close a child scene by the parent scene. Is there another way of doing this for the sake of clean code?

<component name = "scene" extends = "Group" initialFocus = "textrectangle" >

<?xml version="1.0" encoding="utf-8" ?>

<script type = "text/brightscript" >
            sub init()
             end sub
             function onKeyEvent(key as String, press as Boolean) as Boolean
                if press then
                    if key = "back"
                        print "destroy window"
                        m.screen ="scene")
                        m.screen = invalid
                        return true
                    end if
                end if
                return false
             end function


      id = "textRectangle"
      width = "1020"
      height = "560"
      color = "0x000000FF" >

            text = "Text"
            horizAlign = "left"
            vertAlign = "center"
            translation="[10,520]" />

0 Kudos
Roku Guru

Re: Close Child Scene

So this is functioning as you'd like and you're just looking for alternative ways to do it, or is something going wrong with what you have here?
If it's already functioning correctly for you, my opinion of the cleanliness is that this is fine.  What don't you like?
0 Kudos

Re: Close Child Scene

I cannot close this child scene with the following code. The key event occurs but doesn't destroy the scene. I would like to destroy the scene from this xml file and not from the main scene for the sake of not adding more complex code to the main scene.
0 Kudos
Roku Guru

Re: Close Child Scene

Oh I don't think you can do this.  In the RSG app I'm working on, the main scene has tons of logic as it's the top level controller of everything happening.  There's just one scene that stays open the whole time and opens other components by attaching them as child to its containers.  And the one scene has all the logic for controlling (showing and hiding) those containers as if they are different scenes.
0 Kudos
Channel Surfer

Re: Close Child Scene

Agree with joetesta, the conventional approach is to have your screen management logic in the home scene. We have tons of logic to show/hide child nodes in a home scene's key handler.
0 Kudos