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.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
bosborne
Visitor

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")
screen.SetMessagePort(port)
screen.SetListStyle("flat-category")
screen.SetListDisplayMode("photo-fit")

actions = buildMainActions()
screen.SetContentList(actions)
screen.Show()

while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roPosterScreenEvent"
if msg.isListItemSelected()
actionType = actions[msg.GetIndex()]["type"]
if actionType = "categories"
showCategoryScreen(m.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")
screen.setMessagePort(port)
scene = screen.CreateScene("SimpleRowListScene")
screen.show()

while(true)
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 1
EnTerr
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