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: 
bgardella
Visitor

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):

port=CreateObject("roMessagePort")
screen = CreateObject("roGridScreen")
screen.Show()
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
2 REPLIES 2
RokuMarkn
Visitor

Re: Back Button Detection is a nightmare!

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

--Mark
0 Kudos
damon1337
Visitor

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?

Thanks
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.