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: 
youssefsherif
Streaming Star

switching between screens

ive been trying to switch been screens, home screen and details screen through a manager file but its not working for some reason and here is the code can anyone help?Screenshot 2023-02-21 at 7.57.10 PM.pngScreenshot 2023-02-21 at 7.57.21 PM.pngScreenshot 2023-02-21 at 7.57.37 PM.pngScreenshot 2023-02-21 at 7.57.43 PM.png

0 Kudos
7 REPLIES 7
downinit
Channel Surfer

Re: switching between screens

I'm not long into dealing with (learning) Roku, so pardon any non-applicable points.

First glance:

1. Your initscreenstack() in manager.brs doesn't appear to be called, so m.scenegroup isn't instanced.

2. Is the abstraction of [
manager.xml/brs] taking on a controlling duty, rather than the [mainscene.xml/brs], worth it? 

If so:

2b. Don't include the extra <script> for manager.brs in your mainscene.xml. When you want .brs scripts included by multiple components, make them separate .brs files not tied to any components. For example: if component.brs is serving as the script init() backing to component.xml, then don't include that in differentcomponent.xml, otherwise it leads to confusion with unclear context; make a separate shared.brs file.

2c. Then in manager.brs you can change initscreentstack() to init() and it won't conflict.

2d. Then in mainscene.brs at handling the back button, call your interface function for closeScreen: 
m.manager.callFunc("closeScreen"), as you did with showScreen, instead of closeScreen().

3. The mainscene.brs OnKeyEvent doesn't return the result. Though it does in your commented-out version.

Any luck?

youssefsherif
Streaming Star

Re: switching between screens

yup thanks for that i got it and tried it and its not crashing but now the problem is that it is not displaying anything and when i tried to debug it returns an empty component Screenshot 2023-02-22 at 9.46.23 AM.pngScreenshot 2023-02-22 at 9.46.31 AM.pngScreenshot 2023-02-22 at 9.46.42 AM.pngScreenshot 2023-02-22 at 9.46.52 AM.png

<Component: roSGNode:Manager> =
{
    childRenderOrder: "last"
    clippingRect: <Component: roAssociativeArray>
    enableRenderTracking: false
    inheritParentOpacity: true
    inheritParentTransform: true
    muteAudioGuide: false
    opacity: 1
    renderPass: 0
    renderTracking: "disabled"
    rotation: 0
    scale: <Component: roArray>
    scaleRotateCenter: <Component: roArray>
    translation: <Component: roArray>
    visible: true
    change: <Component: roAssociativeArray>
    focusable: false
    focusedChild: <Component: roInvalid>
    id: ""
}
0 Kudos
surendra019
Channel Surfer

Re: switching between screens

Could someone please help me in switching screen from roScreen to roSGScreen and then come back to roScreen

0 Kudos
renojim
Community Streaming Expert

Re: switching between screens

@surendra019, I've mixed roScreen and roSGScreen and it's a bit of a mess.  It depends on what you mean by "come back to roScreen".  I recreate the roScreen after the roSGScreen closes.  I don't try to preserve it and I don't know if it's possible.

At the beginning of RunUserInterface, I create a roScreen that lives for the duration.  Without that, the app would close when the roSGScreen closes.  From there I go back and forth between the two screen types:

  1. Create a dummy roScreen that lives for the duration.
  2. Create a roSGScreen and use it for the UI.
  3. When a choice is made from the UI, create a new roScreen after the roSGScreen closes (or allow the app to exit if the user desires).
  4. Do whatever with the roScreen.
  5. When finished with the roScreen, let it go out of scope or set it to invalid
  6. Go to 2 and repeat as necessary.

I've probably tried variations of this approach over the years, but this is what I've settled on.  I keep waiting for a Roku update to break it.

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
surendra019
Channel Surfer

Re: switching between screens

Yes, I tried that it works, but the issue here is that I have a dialog opened in the roSGScreen and I want open the roScreen on back button pressed, the channel stucks if I try to do that. Actually i am implementing In -app purchases. Here is my project (any help or suggestion would be appreciated)-


https://drive.google.com/file/d/1df2EXQYny1JnO-0VuR6x9k-BoViojgSA/view?usp=sharing

0 Kudos
renojim
Community Streaming Expert

Re: switching between screens

This **bleep**ty "community" site caused me to lose my response, so I'll try to paraphrase it.

You shouldn't call CheckSubscription from your MainScene's init function.  Your code will never reach the statement in Main.brs after "scene = ...".  Let the creation of the scene complete before you start using it.  You also have functions with identical names in different files.  That can only cause confusion.

I think I've only used roChannelStore, not the SG ChannelStore stuff, so I don't know how much help I can be not to mention I hate debugging scene graph.

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
surendra019
Channel Surfer

Re: switching between screens

Sorry for the mistake, could you please tell me then where to call it actually I am a beginner.

0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.