Newbie Q: Understanding How to Bring Up New Screens

I building an app starting from the “Roku Scene Graph – Grid Screen” sample app that comes with the Roku Eclipse Plug-in

It opens with this screen (screen #1):

[upload|NXTuiBtdcw1YnYRBzmWihQ==]

When I click the OK button on the remote, it brings up this screen (screen #2):

[upload|yFBEIkL03RKN3JjzZ2/O3g==]

Where is the line of code that brings up Screen #2?

I’ve been looking for days but haven’t quite figured it out yet. Thanks in advance to all for any info!

Best,

-Vik

I’m looking at “simple grid with video” example, maybe it’s the same or similar enough;

HomeScene.xml has this:

        <field id="rowItemSelected" type="intarray" alwaysnotify="true" alias="GridScreen.rowItemSelected"/>

and HomeScene.brs this:

    m.top.observeField("rowItemSelected", "OnRowItemSelected")

hope this helps!
Joe

If you’re using the Simple_Grid_with_Details_and_Video example, the part of the code I’ve been understanding as displaying that second screen is in the HomeScene.brs. anytime an item is selected on the home grid, the details screen will be set to true:

' Row item selected handler
Function OnRowItemSelected()
    ' On select any item on home scene, show Details node and hide Grid
    m.gridScreen.visible = "false"
    m.detailsScreen.content = m.gridScreen.focusedContent
    m.detailsScreen.setFocus(true)
    m.detailsScreen.visible = "true"
End Function

Is that all it takes to make a screen visible – setting its “visible” property to true?

generally you need to instantiate such a screen first, it won’t exist just by virtue of being in the channel code.
It could be called into exist either by being a child component of a component that’s instantiated, or with something like m.myscreen = createObject(“roSGNode”,“screenID”)

Very good. So after the screen is properly instantiated, can it be displayed just by setting the “visible” property to true?

if its translation places it onscreen and its “visible” value was previously false, then yes.
There can be other things that make it invisible such as opacity = 0 or something else displayed over the top of it.

“VikR0001” wrote:
Very good. So after the screen is properly instantiated, can it be displayed just by setting the “visible” property to true?
If you wanted to remove the detail screen and instead show another screen, yep, as long as you set everything up correctly within the content and the XML I don’t see why it wouldn’t work. Make sure you also include it in the init() function within the .brs file using findNode(). I’m actually attempting to display a new screen as well, depending on the type of video that is clicked on. I’ve successfully been able to solely display the screen but am still working on setting the new content within it so for now its just empty (the hardest part in my opinion!)

Is using the “visible” flag the most common way to reveal a screen? Or are other methods more commonly used?

“VikR0001” wrote:
Is using the “visible” flag the most common way to reveal a screen? Or are other methods more commonly used?
Good question, I’m not really sure. Upon app startup of course there’s .show() in the main function, but from what I’ve seen within the code, I’ve only noticed alot of screen2.visible = true and screen1.visible = false etc.

usually screens are visible by default and the way to bring them up is to create and attach them to the scene.

Thanks for this info, Joe. Could you provide some additional info on the functions used?

In the example I’m looking at “Simple Grid and Video” it has HomeScene.xml that has child components such as “GridScreen”, an overhang, “Video”.
You can create a new screen like this

newscreen = createObject("roSGNode","MyScreenComponent")

(of course you would need an XML and accompanying brs that defines your custom component “MyScreenComponent” as a full screen component, maybe extending Group)
then if it’s created elsewhere, you need to pass that screen node to the HomeScene through a new field defined in HomeScene.xml:

<field id="myScreenNode" type="node" alwaysnotify="true" onChange="newScreenSet"/>

and have HomeScene append it as it’s last child so it appears over top of anything on screen. in HomeScene.brs:

sub newScreenSet()
    newScreen = m.top.myScreenNode
    if newScreen <> invalid 
        m.top.appendChild(newScreen)
    end if
end sub

Awesome. Thanks, @joetesta .