Hi, just getting started with SG, I'm old school SDK trying to catch up. I'm trying to launch a dialog and when user clicks OK, it ends the app. I was trying to use the "dialog example" from Roku.
So what I do is call the below sub which displays the dialog shown in XML file below. My problem is once user clicks OK, I want to close the app. Right now, when I click OK, nothing happens because its doing nothing but returning Boolean value. I'm not sure what I need to call at this point to kill the app. I tried a roUrlTransfer call but it errors out on the SetUrl property ("
http://localhost:8060/keypress/Home"). I assume this type of call won't work in the onKeyEvent so do I need to return focus somehow to the screen so I can close it?
Any help would be appreciated.
sub showChannelSGScreen()
screen = CreateObject("roSGScreen")
m.port = CreateObject("roMessagePort")
screen.setMessagePort(m.port)
scene = screen.CreateScene("DialogExample")
screen.show()
while(true)
msg = wait(0, m.port)
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed()
end if
end if
end while
end sub
XML FILE<component name = "DialogExample" extends = "Scene" >
<script type = "text/brightscript" >
<![CDATA[
sub init()
m.top.backgroundURI = "pkg:/images/rsgde_bg_hd.jpg"
m.top.setFocus(true)
showdialog()
end sub
sub showdialog()
dialog = createObject("roSGNode", "Dialog")
dialog.backgroundUri = "pkg:/images/rsgde_dlg_bg_hd.9.png"
dialog.title = "My title"
dialog.optionsDialog = true
dialog.message = "Press * To Dismiss"
m.top.dialog = dialog
m.top.setFocus(true)
end sub
function onKeyEvent(key as String, press as Boolean) as Boolean
if press then
if (key = "OK") then
return true
end if
end if
return false
end function
]]>
</script>
</component>