Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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
Roku Guru

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