Forum Discussion

jbrave's avatar
jbrave
Channel Surfer
15 years ago

Reload main screen with new content?

The YouTube app let's you search for media from the main poster screen, it then returns you to the Mainposter screen and appends the results to the posteritems displayed in the search section. How would one go about calling search, and having the program flow return to the main poster screen?

If main calls a poster screen which calls search which calls the main poster screen, won't that result in a stack buildup which should eventually cause a memory or stack overflow?

    Main()
      Posterscreen()
        Search()
          Posterscreen()
            Search()
              Posterscreen()
                Search()

Etc....

5 Replies

  • jbrave's avatar
    jbrave
    Channel Surfer
    How would you redisplay the main poster screen? Would it just auto update or do you need to call poster screen.show() again?
  • "jbrave" wrote:
    How would you redisplay the main poster screen? Would it just auto update or do you need to call poster screen.show() again?

    A call to SetContentList() should redraw the screen, but I just deleted my original reply in favor of something that makes more sense... πŸ˜›

    The way I deal with it in my SHOUTcast and justin.tv channels is to have the Search screen just return the search string, and then do the actual search from my Poster screen based on the returned value.
  • And an example...

    Here's my simplified SearchWindow "class"...
    Function NewSearchWindow() As Object
    search = {
    Screen: CreateObject( "roSearchScreen" ),
    EventPort: CreateObject( "roMessagePort" ),
    History: CreateObject( "roSearchHistory" ),

    Show: Search_Show,
    Init: Search_Init,
    ListenForEvents: Search_ListenForEvents
    }
    search.Init()
    return search
    End Function

    Sub Search_Init()
    m.Screen.SetMessagePort( m.EventPort )
    m.Screen.SetSearchTermHeaderText( "Previous searches:" )
    m.Screen.SetSearchButtonText( "Search" )
    m.Screen.SetClearButtonText( "Clear Search History" )
    m.Screen.SetBreadcrumbText( "", "Search" )
    m.Screen.SetSearchTerms( m.History.GetAsArray() )
    End Sub

    Function Search_Show()
    m.Screen.Show()
    Return m.ListenForEvents()
    End Function

    Function Search_ListenForEvents()
    While True
    msg = Wait( 1000, m.EventPort )
    If msg <> invalid Then
    If Type( msg ) = "roSearchScreenEvent" Then
    If msg.IsCleared() Then
    m.History.Clear()
    print "cleared"
    Else If msg.IsPartialResult() Then
    print msg.GetMessage()
    Else If msg.IsFullResult() Then
    m.History.Push( msg.GetMessage() )
    m.Screen.Close()
    Return msg.GetMessage()
    Else If msg.isScreenClosed() Then
    Return "Cancel"
    End If
    End If
    End If
    End While
    Return "Cancel"
    End Function

    From my poster screen, I do something like this:

    If buttonSelected = "Search" Then
    searchWin = NewSearchWindow()
    searchTerm = searchWin.Show()
    If searchTerm <> invalid And searchTerm <> "Cancel" Then
    'Do search based on searchTerm
    End If
    End If
  • jbrave's avatar
    jbrave
    Channel Surfer
    So the buttonpressed func is called from the poster screen msg loop?
  • Yeah, however you trigger that in your channel. In my case, I have a "Search" content item in my content list. If that one's selected, I call the code above.