chaklasiyanikun
6 years agoRoku Guru
Inside a task node open a dialogbox in Roku
I know task node works like thread and not support dialog inside a task node. But, Is there any way to open a dialog box inside a task node. I also used getparent(). But no luck.
my code is below.
url="URL is Here" m.req=createobject("roURLTransfer") m.req.seturl(url) m.port=createobject("roMessagePort") m.req.setport(m.port) m.req.asyncgettostring() while true msg=wait(100,m.port) '100 millisecond pause if type(msg)="roUrlEvent" then if msg.getresponsecode()=200 then data=msg.getstring() headers=msg.getresponseheadersarray() exit while else m.req.asynccancel() ' Here I tried to print a dialog box warningdialog = CreateObject("roSGNode", "Dialog") warningdialog.title = "Warning" warningdialog.message = "Not Valid Request." warningdialog.buttons = ["Ok"] m.top.dialog = warningdialog m.top.dialog.observeField("buttonSelected", "warning") end if end if end while
Here give me a warning not to exist dialog field. Is there any other option for this?
chaklasiyanikun wrote:...
Here give me a warning not to exist dialog field. Is there any other option for this?
seems to me you were on the right track, since wanting to display a modal dialog and that is easy to do using the .dialog field of the Scene. So you just have to grab the scene with getScene().
i'd do something like this:
dlg = createObject("roSGNode", "Dialog") port2 = createObject("roMessagePort") dlg.observeField("buttonSelected", port2) dlg.observeField("wasClosed", port2) dlg.title = "Warning" dlg.message = "Not a valid URL request" dlg.buttons = ["OK"] dlg.getScene().dialog = dlg while wait(0, port2) = invalid ' pass end while dlg.close = true 'out of propriety