Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
dbulli
Level 7

Re: AddButton on an roPosterScreen

I am seeing the same thing where the back button doesn't close the screen and no event is being fired. Up button does close the PosterScreen
- Daniel
http://dbulli.com
0 Kudos
TheEndless
Level 9

Re: AddButton on an roPosterScreen

"dbulli" wrote:
I am seeing the same thing where the back button doesn't close the screen and no event is being fired. Up button does close the PosterScreen

Where are you seeing this? On a channel you wrote? Back works fine on a poster screen for me.
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)
0 Kudos
RokuJoel
Roku Employee
Roku Employee

Re: AddButton on an roPosterScreen

I am seeing the same thing where the back button doesn't close the screen and no event is being fired. Up button does close the PosterScreen


This issue usually means you are not handling the isScreenClosed() event properly. Usually adding:

else if msg.isscreenclosed()
return -1


will do the trick.
0 Kudos
jlfreund
Level 7

Re: AddButton on an roPosterScreen

I can't get up or back to work on my roPosterScreen. I want both (or at least either) of those buttons to be handled in my


else if msg.isScreenClosed() then
print "Screen closed"
return -1
endif


block, so my app can redraw the parent menu, but that code is never called. Back key exits the app completely and up key either navigates up from the content list to the filter banner, or from filter banner, up key will exit the app (without printing "Screen closed"). I even put a "stop" after the line "if type(msg) = "roPosterScreenEvent" then", and the script does not break there, so "back" and "Up" are not making it into my event loop.

I'd really hate to have a content item called "Go back to previous menu", so any help on how to handle buttons in roPosterScreen would be appreciated Smiley Happy
0 Kudos
jlfreund
Level 7

Re: AddButton on an roPosterScreen

Hi,

I attached a sample app showing my problem handling a Back or Up key in my app. The app puts 3 category names in the filter banner, and 3 items in the content list. To reproduce the problem, just run the app, move down from the filter banner to the first content item, and select it. The app will reset the categories and list items with a new menu, and from there if you press Back or Up, it will simply exit the app rather than getting handled in the roPosterScreenEvent message handler. The expected behavior is that it should print "isScreenClosed", return from the function, and redraw the parent menu.


'******************************************************************************
Function InitPosterScreen(screen As Object, level As String)

categoryArray = CreateObject("roArray", 5, true)
categoryArray[0] = "C1 " + level
categoryArray[1] = "C2 " + level
categoryArray[2] = "C3 " + level
screen.SetListNames(categoryArray)
screen.SetFocusedList(0)

itemsArray = CreateObject("roArray", 5, true)
item = CreateObject("roAssociativeArray")
item.ShortDescriptionLine1 = "Item1a" + level
item.ShortDescriptionLine2 = "Item1b" + level
itemsArray.Push(item)
item = CreateObject("roAssociativeArray")
item.ShortDescriptionLine1 = "Item2a" + level
item.ShortDescriptionLine2 = "Item2b" + level
itemsArray.Push(item)
item = CreateObject("roAssociativeArray")
item.ShortDescriptionLine1 = "Item3a" + level
item.ShortDescriptionLine2 = "Item3b" + level
itemsArray.Push(item)

screen.SetContentList(itemsArray)
screen.SetFocusedListItem(0)
End Function

'******************************************************************************
Function ShowMenu(screen As Object, level As String) As Integer
InitPosterScreen(screen, level)
screen.Show()

while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roPosterScreenEvent" then
print "roPosterScreenEvent | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
if msg.isListFocused() then
print "Category focused | index = "; msg.GetIndex(); " | category = "; m.curCategory
else if msg.isButtonPressed() then
print "isButtonPressed" ; msg.GetIndex()
else if msg.isListItemSelected() then
print "isListItemSelected | index = "; msg.GetIndex()
' Show second level menu, Up or Back key should be handled in isScreenClosed() handler and return to caller.
print "Showing second level"
ShowMenu(screen, "- Level 2")

print "Done showing second level"
InitPosterScreen(screen, "- Level 1")
else if msg.isScreenClosed() then
print "isScreenClosed()"
return -1
end if
end If
end while

return 1
End Function

'******************************************************************************
Sub Main()
port = CreateObject("roMessagePort")
screen = CreateObject("roPosterScreen")
screen.SetMessagePort(port)
screen.SetListStyle("flat-category")
screen.setAdDisplayMode("scale-to-fit")

ShowMenu(screen, " - Level 1")
End Sub
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: AddButton on an roPosterScreen

You only have one roPosterScreen, so when it closes the channel exits. That's normal behavior.

The way you're using recursion and passing a single screen around is probably the root of the problem. For UP and BACK to work correctly, your UI should be a stack of multiple screens.
0 Kudos
jlfreund
Level 7

Re: AddButton on an roPosterScreen

Thanks for the reply, that worked!

Jason
0 Kudos