Forum Discussion

xoceunder's avatar
xoceunder
Roku Guru
9 years ago

Helps to enter another Scene

This is my test code

main.brs

'********** Copyright 2016 Roku Corp.  All Rights Reserved. **********

sub RunUserInterface()
  screen = CreateObject("roSGScreen")
  m.port = CreateObject("roMessagePort")
  screen.setMessagePort(m.port)
  scene = screen.CreateScene("MenuList")
  
  screen.show()

  while(true)
    msg = wait(0, m.port)
    msgType = type(msg)
    if msgType = "roSGNodeEvent"
      if msg.isScreenClosed() then return
    end if
  end while

end sub




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

<component name = "MenuList" extends = "Scene" initialFocus = "Buttons" >

  <script type = "text/brightscript" >

    <![CDATA[

    sub init()
      m.top.backgroundURI = "pkg:/images/rsgde_bg_hd.jpg"

      m.top.setFocus(true)
    end sub

   ' on Button press selected
   Sub onItemSelected()
   
print "Boton "; m.top.itemSelected
    if m.top.itemSelected = 0

m.scene.findNode("epgGridScene")
else if m.top.itemSelected = 1

    end if
   End Sub
  

    ]]>

  </script>
  
    <interface>
        <!-- Button press handler -->
        <field id="itemSelected" type="integer" alwaysnotify="true" alias="Buttons.itemSelected" onChange="onItemSelected" />
    </interface>

  <children >
  
     <LabelList
            id="Buttons"
focusRow = "0"
itemSize = "[440,48]"
            translation="[150,150]"
            color="0xFFFFFFFF"
            focusedColor="0x333333FF"
            numRows="5"
            sectionDividerHeight = "48.0"
            sectionDividerFont = "font:MediumBoldSystemFont"
            sectionDividerTextColor = "0x880088FF">

      <ContentNode role = "content" >
<ContentNode title = "Livetv" HDLISTITEMICONSELECTEDURL="pkg:/images/icon-logo-design-small.png" HDLISTITEMICONURL = "pkg:/images/icon-logo-design-small.png"/>
        <ContentNode title = "Movies" HDLISTITEMICONSELECTEDURL="pkg:/images/icon-logo-design-small.png" HDLISTITEMICONURL = "pkg:/images/icon-logo-design-small.png"/>
        <ContentNode title = "Series" HDLISTITEMICONSELECTEDURL="pkg:/images/icon-logo-design-small.png" HDLISTITEMICONURL = "pkg:/images/icon-logo-design-small.png"/>
        <ContentNode title = "Events" HDLISTITEMICONSELECTEDURL="pkg:/images/icon-logo-design-small.png" HDLISTITEMICONURL = "pkg:/images/icon-logo-design-small.png" />
<ContentNode title = "Adutls" HDLISTITEMICONSELECTEDURL="pkg:/images/icon-logo-design-small.png" HDLISTITEMICONURL = "pkg:/images/icon-logo-design-small.png" />
<ContentNode title = "Sports" HDLISTITEMICONSELECTEDURL="pkg:/images/icon-logo-design-small.png" HDLISTITEMICONURL = "pkg:/images/icon-logo-design-small.png" />
        <ContentNode title = "Setings" HDLISTITEMICONSELECTEDURL="pkg:/images/icon-logo-design-small.png" HDLISTITEMICONURL = "pkg:/images/icon-logo-design-small.png" />

      </ContentNode>

    </LabelList>

  </children>

</component>




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

<!--********** Copyright 2015 Roku Corp.  All Rights Reserved. **********-->

<component name="epgGridScene" extends="Scene">

   <children>
    <Video
    id="Video"
    translation = "[1100, 70]"
    width = "760"
    height= "340"/>
      <!-- EPG Grid -->
      <customEPGGrid />
   </children>
</component>



But I'm throwing this error

BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Suspending threads...
Thread selected:  1*   pkg:/components/MenuScene.xml(30)       m.scene.findNode("epgGridScene")

Current Function:
025:     Sub onItemSelected()
026:      ' first button is Play
027:    print "Boton "; m.top.itemSelected
028:      if m.top.itemSelected = 0
029:          'print "Second 1 "
030:*       m.scene.findNode("epgGridScene")
031:    else if m.top.itemSelected = 1
032:          'print "Second 2 "
033:      end if
034:     End Sub
Interface not a member of BrightScript Component (runtime error &hf3) in pkg:/components/MenuScene.xml(30)
030:        m.scene.findNode("epgGridScene")
Backtrace:
#0  Function onitemselected() As Void
   file/line: pkg:/components/MenuScene.xml(30)
Local Variables:
global           Interface:ifGlobal
m                roAssociativeArray refcnt=2 count:2
Threads:
ID    Location                                Source Code
 0    pkg:/source/main.brs(12)                msg = wait(0, m.port)
 1*   pkg:/components/MenuScene.xml(30)       m.scene.findNode("epgGridScene")
  *selected

8 Replies

  • destruk's avatar
    destruk
    Streaming Star
    AFAIK you can only have one extends="scene" component.
    The component element requires 2 things -- a unique name, and "Extends" - The name of the built-in node class, or extended component, that the component extends
    If you want multiple screens, use extends="Group", or extends="Task", or the name of the node is based upon for your modifications.
  • "destruk" wrote:
    AFAIK you can only have one extends="scene" component.
    The component element requires 2 things -- a unique name, and "Extends" - The name of the built-in node class, or extended component, that the component extends
    If you want multiple screens, use extends="Group", or extends="Task", or the name of the node is based upon for your modifications.

    I do not quite understand what you mean, you could explain where to change that please
  • destruk's avatar
    destruk
    Streaming Star
    I can't write all the code for you but these files ought to help -

    MenuList.xml (extension of scene and main home screen of the scenegraph)
    <?xml version = "1.0" encoding = "utf-8" ?>

    <component name = "MenuList" extends = "Scene" initialFocus = "Buttons" >

      <script type = "text/brightscript" >

        <![CDATA[

        sub init()
          m.top.backgroundURI = "pkg:/images/rsgde_bg_hd.jpg"
          m.grid=m.top.findNode("epgGridScene")
          m.labellist=m.top.findNode("Buttons")
          m.labellist.setFocus(true)
        end sub
     
       ' on Button press selected
       Sub onItemSelected()
       
     print "Button "; m.labbellist.itemSelected
        if m.labellist.itemSelected = 0
      m.grid.visible=TRUE
    'm.grid.setfocus(TRUE)
     else if m.labellist.itemSelected = 1
      m.grid.visible=FALSE
        end if
       End Sub
      

        ]]>

      </script>
      
        <interface>
            <!-- Button press handler -->
            <field id="itemSelected" type="integer" alwaysnotify="true" alias="Buttons.itemSelected" onChange="onItemSelected" />
        </interface>

      <children >
      
         <LabelList
                id="Buttons"
     focusRow = "0"
     itemSize = "[440,48]"
                translation="[150,150]"
                color="0xFFFFFFFF"
                focusedColor="0x333333FF"
                numRows="5"
                sectionDividerHeight = "48.0"
                sectionDividerFont = "font:MediumBoldSystemFont"
                sectionDividerTextColor = "0x880088FF">

          <ContentNode role = "content" >
            <ContentNode title = "Livetv" HDLISTITEMICONSELECTEDURL="pkg:/images/icon-logo-design-small.png" HDLISTITEMICONURL = "pkg:/images/icon-logo-design-small.png"/>
            <ContentNode title = "Movies" HDLISTITEMICONSELECTEDURL="pkg:/images/icon-logo-design-small.png" HDLISTITEMICONURL = "pkg:/images/icon-logo-design-small.png"/>
            <ContentNode title = "Series" HDLISTITEMICONSELECTEDURL="pkg:/images/icon-logo-design-small.png" HDLISTITEMICONURL = "pkg:/images/icon-logo-design-small.png"/>
            <ContentNode title = "Events" HDLISTITEMICONSELECTEDURL="pkg:/images/icon-logo-design-small.png" HDLISTITEMICONURL = "pkg:/images/icon-logo-design-small.png" />
     <ContentNode title = "Adutls" HDLISTITEMICONSELECTEDURL="pkg:/images/icon-logo-design-small.png" HDLISTITEMICONURL = "pkg:/images/icon-logo-design-small.png" />
     <ContentNode title = "Sports" HDLISTITEMICONSELECTEDURL="pkg:/images/icon-logo-design-small.png" HDLISTITEMICONURL = "pkg:/images/icon-logo-design-small.png" />
            <ContentNode title = "Setings" HDLISTITEMICONSELECTEDURL="pkg:/images/icon-logo-design-small.png" HDLISTITEMICONURL = "pkg:/images/icon-logo-design-small.png" />
     
          </ContentNode>

        </LabelList>
    <!-- epgGridScreen -->
    <epgGridScreen
    id="epgGridScreen"
    visible="FALSE"/>

      </children>

    </component>



    epgGridScreen.xml extends Group - 
    <?xml version="1.0" encoding="utf-8" ?> 

    <!--********** Copyright 2015 Roku Corp.  All Rights Reserved. **********-->

    <component name="epgGridScreen" extends="Group">

       <children>
        <Video
        id="Video"
        translation = "[1100, 70]"
        width = "760"
        height= "340"/>
          <!-- EPG Grid -->
          <customEPGGrid />
       </children>
    </component>
  • =================================================================
    Error creating XML component MenuList
    -- Could not create node of unknown type "epgGridScreen"
    -- Error found at line 37 of file pkg:/components/MenuList.xml
    =================================================================

    line 37 = <epgGridScreen id="epgGridScreen" visible="FALSE"/>
  • I have a problem that when entering the epg grid I do not want to work and neither return to the menulist
  • Someone could help me with the test code that I'm testing that does not want me to work