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
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)