Roku Developer Program

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

Back button triggers too many events?

I can't explain what is happening. I'm experimenting with combining some of the traditional poster screens with the new scene API.

Here's some sample code, where the first screen presents a list of icons, and once you click an icon, it launches a scene. The problem is that when I back out of the scene (using back button), it ALSO backs out of the first poster screen. The port on the first poster screen receives a screen close event for no apparent reason:

Function showHomeScreen()
port = CreateObject("roMessagePort")
screen = CreateObject("roPosterScreen")

actions = buildMainActions()

while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roPosterScreenEvent"
if msg.isListItemSelected()
actionType = actions[msg.GetIndex()]["type"]
if actionType = "categories"
end if
else if msg.isScreenClosed()
exit while
end if
end If
end while
End Function

Function showCategoryScreen(categories)
screen = CreateObject("roSGScreen")
port = CreateObject("roMessagePort")
scene = screen.CreateScene("SimpleRowListScene")

msg = wait(0, port)
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed()
exit while
end if
end if
end while
End Function

There's some other code in there that's not important to demonstrate the example. So, I can successfully get the category scene to launch. When I back out of it, an event is fired for closing the screen and the while loop is exited. At that point I would expect the user to be shown the original poster screen and can perform another action. Instead, they are presented with the screen briefly but it closes as well! It received an event that closed the screen as well.

Can anyone explain that?
0 Kudos
1 Reply
Level 10

Re: Back button triggers too many events?

Looks weird. I havent tried the graphic scenes but seems weird regardless.
Have you tried dumping (printing) the events in each loop to maybe get better idea what's going on?
0 Kudos