content: ' ********** Copyright 2016 Roku Corp.  All Rights Reserved. ********** 
   ' inits grid screen
   ' creates all children
   ' sets all observers 
  Function Init()
      ' listen on port 8089
      ? "[HomeScene] Init"
  
      ' GridScreen node with RowList
      m.gridScreen = m.top.findNode("GridScreen")
  
      ' DetailsScreen Node with description, Video Player
      m.detailsScreen = m.top.findNode("DetailsScreen")
  
      ' Observer to handle Item selection on RowList inside GridScreen (alias="GridScreen.rowItemSelected")
      m.top.observeField("rowItemSelected", "OnRowItemSelected")
      
      ' loading indicator starts at initializatio of channel
      m.loadingIndicator = m.top.findNode("loadingIndicator")
  End Function 
  
  ' if content set, focus on GridScreen
  Function OnChangeContent()
      m.gridScreen.setFocus(true)
      m.loadingIndicator.control = "stop"
  End Function
  
  ' 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
  
  ' Main Remote keypress event loop
  Function OnKeyEvent(key, press) as Boolean
      ? ">>> HomeScene >> OnkeyEvent"
      result = false
      if press then
          if key = "options"
              ' option key handler
          else if key = "back"
  
              ' if Details opened
              if m.gridScreen.visible = false and m.detailsScreen.videoPlayerVisible = false
                  m.gridScreen.visible = "true"
                  m.detailsScreen.visible = "false"
                  m.gridScreen.setFocus(true)
                  result = true
  
              ' if video player opened
              else if m.gridScreen.visible = false and m.detailsScreen.videoPlayerVisible = true
                  m.detailsScreen.videoPlayerVisible = false
                  result = true
              end if
  
          end if
      end if
      return result
  End Function
  