Roku Developer Program

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

Multiple Dialogs

Hi,

I have opened options dialog and trying to open the Help in another dialog by closing the options dialog but it is not working, it makes the roku to restart

My code 

function onKeyEvent(key as String, press as Boolean) as Boolean
if key="options"
dialog = createObject("roSGNode", "Dialog")
dialog.title = "Options"
dialog.buttons = ["Help","Feedback","Terms of Use","Privacy Policy","Sign In/Sign Out"]
dialog.observeField("buttonSelected","onbuttonClick")
dialog.optionsDialog = true
m.top.dialog = dialog
end if
end function

sub onbuttonClick()
print m.top.dialog.buttonSelected
if m.top.dialog.buttonSelected = 0
adialog = createObject("roSGNode", "Dialog")
adialog.title = "HELP"
adialog.message = "Kindly visit the following URL http://www.xyz.com"
adialog.optionsDialog = true
m.top.dialog = adialog
end if
end sub

any idea why the roku closes automatically and restarts?
0 Kudos
9 Replies
gabek
Level 7

Re: Multiple Dialogs

This also happens to me when trying to replace one Dialog with another.
0 Kudos
jeswin
Level 7

Re: Multiple Dialogs

ok

Have anyone find a solution?
0 Kudos
cbeatson
Level 7

Re: Multiple Dialogs

I have the same problem.  Trying to show a second dialog after closing the first causes the roku to reboot.  Does the dialog node need to be re-initialized or some such before trying to assign another dialog object to it ? 
0 Kudos
cbeatson
Level 7

Re: Multiple Dialogs

I found a workaround to this issue.  Use a single, global to the thread, dialog object to assign to the m.top.dialog node.  i.e:  m.dialog = createObject("roSGNode", "Dialog") . Then after the initial launch, you'll need to remove the close field and reset any other fields accordingly before re-assigning it to m.top.dialog.  i.e. m.dialog.removeField("close") etc.  It seems that by using the same Dialog object to assign to the dialog node of the scene, it won't cause the crash.  

Should work until the underlying issue is fixed, or documentation is updated accordingly to reflect this. 

Hope this helps.
Chris
0 Kudos
bounce
Level 7

Re: Multiple Dialogs

I too am having the same issue. Can you describe the workaround? It doesn't seem to be a sensible solution for me.

Can Roku Engineers comment?

I'm trying to spawn from a dialog to a keyboard dialog. IE Options Menu to Search Menu.
0 Kudos
gomad
Level 7

Re: Multiple Dialogs

I am not sure if you can have nested dialog components.
You can give this a try:
E.g:
dialog = m.top.createChild("Dialog")
    MainSceneNode = m.top.getScene()
    MainSceneNode.dialog = dialog

and for closing:
function dismissPopupDialog()
    ?"---Dismiss popup---"
     MainSceneNode = m.top.getScene()
    if MainSceneNode.dialog <> invalid then
        MainSceneNode.dialog.close = true
    end if
0 Kudos
bounce
Level 7

Re: Multiple Dialogs

You helped me get an idea.

I did try your suggestion with no luck, maybe try it on your own roku device and see if you can get it working.

I was however, able to put the dialog in another thread and run it, astonishingly it worked. However, you do lose a lot of the context to the top scene due to it being in a different thread. I hope someone can come in here and provide an answer. Maybe someone with Roku dev team.

Here is some code I used...

    dismissPopupDialog()
    m.searchTask = createObject("RoSGNode","SearchTask")
    m.searchTask.control = "RUN"
0 Kudos
gomad
Level 7

Re: Multiple Dialogs

The code I shared works for me on Roku3/4/Stick/+ .
It basically try to launch/create a dialog from the MainScene. I think that is what was mentioned in the docs also for Dialogs.
0 Kudos
bounce
Level 7

Re: Multiple Dialogs

I had to do something similar to your code above. However had to throw it in a different thread and do an observeField which would call back once the search was completed. Hopefully this will help someone else trying to do the same.
0 Kudos