This component is deprecated.
Beginning July 1st, 2017, any new channels using this component will be rejected during certification.
Beginning January 1st, 2018, any updates to existing channels using this component will be rejected during certification.
The Search Screen provides a standard way to allow users to enter text for searching.
Supported Interfaces
Note: some firmware versions may implement ifSearchScreen as ifRoSearchScreen.
Events
Description
This screen features a simplified keyboard (a-z, 0-9) designed to provide just the keys necessary to perform case-insensitive searches without punctuation.
Ideally, the user would enter a search string and the backend service would perform that query in a case-insensitive manner ignoring special characters like punctuation. The script is notified as each key is pressed so that a progress disclosure search can be performed if supported by the back-end service. In addition, the script can control the text displayed on the screen and will receive events when the text entry is complete.
In addition to entering search strings, this screen features a list that can be used to display search results or show the most recent searches. It's desirable for the screen to maintain a list of recent searches for the user to allow them to easily repeat a recent query without typing. In some implementations, it may be desirable to use this list to show a progressive set of results after each character while the user is typing.
This object is created with no parameters:
CreateObject("roSearchScreen")
REM ****************************************************** REM Main routine - example of search screen usage REM ****************************************************** Sub Main() print "start" 'toggle the search suggestions vs. search history behavior 'this allow you to generate both versions of the example below displayHistory = false history = CreateObject("roArray", 1, true) 'prepopulate the search history with sample results history.Push("seinfeld") history.Push("fraiser") history.Push("cheers") port = CreateObject("roMessagePort") screen = CreateObject("roSearchScreen") 'commenting out SetBreadcrumbText() hides breadcrumb on screen screen.SetBreadcrumbText("", "search") screen.SetMessagePort(port) if displayHistory screen.SetSearchTermHeaderText("Recent Searches:") screen.SetSearchButtonText("search") screen.SetClearButtonText("clear history") screen.SetClearButtonEnabled(true) 'defaults to true screen.SetSearchTerms(history) else screen.SetSearchTermHeaderText("Suggestions:") screen.SetSearchButtonText("search") screen.SetClearButtonEnabled(false) endif print "Doing show screen..." screen.Show() print "Waiting for a message from the screen..." ' search screen main event loop done = false while done = false msg = wait(0, screen.GetMessagePort()) if type(msg) = "roSearchScreenEvent" if msg.isScreenClosed() print "screen closed" done = true else if msg.isCleared() print "search terms cleared" history.Clear() else if msg.isPartialResult() print "partial search: "; msg.GetMessage() if not displayHistory screen.SetSearchTerms(GenerateSearchSuggestions(msg.GetMessage())) endif else if msg.isFullResult() print "full search: "; msg.GetMessage() history.Push(msg.GetMessage()) if displayHistory screen.AddSearchTerm(msg.GetMessage()) end if 'uncomment to exit the screen after a full search result: 'done = true else print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage() endif endif endwhile print "Exiting..." End Sub Function GenerateSearchSuggestions(partSearchText As String) As Object availableContent = [ "ghost in the shell" "parasite dolls" "final fantasy" "ninja scroll" "space ghost" "hellboy" "star wars" "terminator" "house of cards" "dexter" ] suggestions = [] if partSearchText <> "" partSearchText = LCase(partSearchText) for each available in availableContent if available.Instr(partSearchText) >= 0 suggestions.Push(available) end if end for end if return suggestions End Function
Image: roSearchScreen example results (search suggestions)
Image: roSearchScreen example results (search history)