Available since firmware version 7.0

The ifRoSGScreen interface allows creation and initialization of a SceneGraph scene.

Implemented by

Supported Methods

Description of Methods 

CreateScene(sceneType as String) as Object

Creates the SceneGraph scene object defined by the roSGScreen object identified by sceneType.

GetScene() as roSGNode

This function returns the roSGScene object associated with the screen.  This is the scene generally created in main.brs by a roSGScreen.CreateScene() call.

SetMessagePort(port as roMessagePort)

Specifies the roMessagePort object identified as port as the message port object for the roSGScreen object.

GetMessagePort() as roMessagePort

Returns the roMessagePort object for the subject SceneGraph scene.

Show()

Renders the SceneGraph scene defined by the roSGScreen object on the display screen.

Close()

Removes the SceneGraph scene from the display screen.

getGlobalNode() as roSGNode

Available since firmware version 7.1

Returns a global reference object for the SceneGraph application.

Starting Scene Graph Applications
sub showChannelSGScreen()  
  print "in showChannelSGScreen" 
  screen = CreateObject("roSGScreen") 
  m.port = CreateObject("roMessagePort") 
  screen.setMessagePort(m.port) 
  m.global = screen.getGlobalNode() 
  m.global.id = "GlobalNode" 
  m.global.addFields( {red: &hff0000ff, green: &h00ff00ff, blue: &h0000ffff} ) 
  scene = screen.CreateScene("TrivialScene") 
  screen.show() 
  scene.setFocus(true) 

  child = createObject("RoSGNode","ContentNode") 
  child.contentkey = "test_string" 
  print "child: '"; child.contentkey; "'" 

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

end sub
Accessing Global Fields
<?xml version="1.0" encoding="utf-8" ?>

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

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

  <interface>
  </interface>

  <children>

    <LayoutGroup 
      id = "Stuff" 
      translation = "[100,100]" 
      layoutDirection="horiz" 
      vertAlignment="center" 
      itemSpacings="[10]" >

      <Rectangle id = "Rect1" width = "200" height = "100" />

    </LayoutGroup>

  </children>

  <script type="text/brightscript" >

    <![CDATA[
      function init() 
        print "TrivialScene init()"
        m.top.id = "top_TrivialScene"
        m.rect = m.top.findNode("Rect1")
        m.rect.color = m.global.red
        m.count = 0 
        m.top.observeField("rectcolor","rectColorChanged")
      end function

      function rectColorChanged() 
        print "rect.color changed to"; m.rect.color
      end function

      function onKeyEvent(key as String, press as Boolean) as Boolean 
        print "key '"; key; "' pressed "; press; " on node '"; m.top.id; "'" 
        if key = "OK" and press 
          m.count = m.count + 1 
          color = m.rect.color  
          if m.rect.color = m.global.red 
            m.rect.color = m.global.green 
          else if m.rect.color = m.global.green 
            m.rect.color = m.global.blue 
          else 
            m.rect.color = m.global.red 
          end if 
        end if  
      return true 
    end function
    ]]>

  </script>

</component>