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 Detection is a nightmare!

I've seen some good advice about back button detection, such as making sure dialogs are closed, etc. And I'm not a beginner at all. But my channel has major inconsistencies about when the back button events are captured in event loops. ANY advice about this would be appreciated. Here's my example:

I open an "roGridScreen" and wait loop as usual (code is condensed for brevity):

screen = CreateObject("roGridScreen")
while true
msg = wait(0, port)
if msg <> invalid AND msg.isScreenClosed() then
print "back button on Main Grid DETECTED!"
return ""
end if
'''''more logic that ultimately opens a second grid...
returnState = ShowSecondGrid()
'''''more logic to handle returnState
end while

What I find baffling is that the back button will not work initially. But if I open the second grid, it will respond to "back" and then the primary grid ALSO responds to back, i.e. msg.isScreenClosed()

Any ideas what I'm not catching?
0 Kudos
Level 8

Re: Back Button Detection is a nightmare!

Aren't you missing a call to SetMessagePort to associate the port with the screen?

0 Kudos
Level 7

Re: Back Button Detection is a nightmare!

I feel ya man. I think roMessageDialogEvent must not count the back button as a screenClosed event. Home counted for me but back wouldn't.

:arrow: :evil:

Can anybody confirm?

0 Kudos