m.callDialog=CreateObject("RoSGNode", "dialogTask")
m.callDialog.titles="TEST"
m.callDialog.messages="TEST TEST"
m.calldialog.control="RUN"
<?xml version="1.0" encoding="UTF-8"?>
<component name="dialogTask" extends="Task">
<interface>
<field id="titles" type="string" />
<field id="messages" type="string" />
</interface>
<script type="text/brightscript" uri="pkg:/components/dialogs/dialog.brs" />
<script type = "text/brightscript" >
<![CDATA[
sub init()
?"in dialogTask"
m.top.functionName="dialog"
end sub
]]>
</script>
</component>
<?xml version = "1.0" encoding = "utf-8" ?>
<!--********** Copyright 2016 Roku Corp. All Rights Reserved. **********-->
<component name = "dialogInfoScene" extends = "Scene" >
<script type="text/brightscript" uri="pkg:/components/dialogs/dialog.brs" />
<script type = "text/brightscript" />
<children>
<Label
id = "instructLabel"
text = "" />
<Poster
id="Background"
width="1280"
height="720"
/>
</children>
</component>
function Dialog()
?"in Dialogs"
titlevalue=m.top.titles
messagevalue=m.top.messages
m.background = m.top.findNode("Background")
example = m.top.findNode("instructLabel")
examplerect = example.boundingRect()
centerx = (1280 - examplerect.width) / 2
centery = (720 - examplerect.height) / 2
example.translation = [ centerx, centery ]
m.top.setFocus(true)
di = CreateObject ("roDeviceInfo")
serial=di.GetDeviceUniqueId()
dialog = createObject("roSGNode", "Dialog")
dialog.title = titlevalue
dialog.optionsDialog = true
dialog.message =messagevalue
m.top.dialog = dialog
end function
"btpoole" wrote:
=================================================================
Warnings occurred while spawning thread for Task component dialogTaskRegistry
spawning thread aborted because: channel exit or timeout waiting for render thread
=================================================================
"RokuNB" wrote:"btpoole" wrote:
=================================================================
Warnings occurred while spawning thread for Task component dialogTaskRegistry
spawning thread aborted because: channel exit or timeout waiting for render thread
=================================================================
Methinks your problem is elsewhere.
"btpoole" wrote:
Can you tell me if it is possible to set the title and message of a dialog box thru a task, then call the dialog? Just looking to have one dialog that can be used thru out the app with dynamic title and message.
"RokuNB" wrote:"btpoole" wrote:
Can you tell me if it is possible to set the title and message of a dialog box thru a task, then call the dialog? Just looking to have one dialog that can be used thru out the app with dynamic title and message.
My apologies, since i dont have time to take your code and make it work - but I know no reason why this would be impossible. I also don't know a reason of why you should be using a Task for that and not do it directly. The problem you saw seems to be because your app exits before that or there is some other timeout happening.
function generalScene()
?"in generalScene"
screen = CreateObject("roSGScreen")
screen.setMessagePort(m.port)
scene = screen.CreateScene("generalInfoScene")
screen.show()
while (true)
msg = wait(0, m.port)
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed()
EXIT WHILE
end if
end if
end while
end function
<?xml version = "1.0" encoding = "utf-8" ?>
<!--********** Copyright 2016 Roku Corp. All Rights Reserved. **********-->
<component name = "generalInfoScene" extends = "Scene" >
<interface>
<field id="title" type = "string" />
</interface>
<script type="text/brightscript" uri="pkg:/source/main.brs" />
<script type = "text/brightscript" >
<![CDATA[
sub init()
generalDialog()
end sub
sub generalDialog()
m.background = m.top.findNode("Background")
example = m.top.findNode("instructLabel")
examplerect = example.boundingRect()
centerx = (1280 - examplerect.width) / 2
centery = (720 - examplerect.height) / 2
example.translation = [ centerx, centery ]
m.top.setFocus(true)
dialog = createObject("roSGNode", "Dialog")
dialog.title = m.top.title
dialog.optionsDialog = true
dialog.message = "TEST MESSAGE"
m.top.dialog = dialog
end sub
]]>
</script>
<children>
<Label
id = "instructLabel"
text = "" />
<Poster
id="Background"
width="1280"
height="720"
/>
</children>
</component>
"btpoole" wrote:
How would I set the title in the scene dynamically so the same code could be used to display different a different title and message? I know how to set a field in a task but not sure about the scene.
sub generalDialog(title, message)
dialog = createObject("roSGNode", "Dialog")
dialog.title = title
dialog.message = messsage
dialog.optionsDialog = true
m.top.dialog = dialog
end sub
"RokuNB" wrote:"btpoole" wrote:
How would I set the title in the scene dynamically so the same code could be used to display different a different title and message? I know how to set a field in a task but not sure about the scene.
Just the same, something like:
sub generalDialog(title, message)
dialog = createObject("roSGNode", "Dialog")
dialog.title = title
dialog.message = messsage
dialog.optionsDialog = true
m.top.dialog = dialog
end sub
"RokuNB" wrote:"btpoole" wrote:
How would I set the title in the scene dynamically so the same code could be used to display different a different title and message? I know how to set a field in a task but not sure about the scene.
Just the same, something like:
sub generalDialog(title, message)
dialog = createObject("roSGNode", "Dialog")
dialog.title = title
dialog.message = messsage
dialog.optionsDialog = true
m.top.dialog = dialog
end sub
Sub RunUserInterface()
Print "RUNUSERINTERFACE"
screen = CreateObject("roSGScreen")
port = CreateObject("roMessagePort")
screen.setMessagePort(port)
scene = screen.CreateScene("BusySpinnerExample")
screen.show()
presetup()
end sub
sub presetup()
response=usercheck()
if response= 1
checkStatus()
else
do something else
end if
end sub
function checkstatus()
if m.global.info=0
dialogtitle= "TITLE OF 0"
dialogmessage= "0 message here"
else
dialogtitle= "TITLE NOT 0"
dialogmessage= "NOT 0 message here"
end if
m.utility=createobject("rosgnode", "utilityScene")
m.utility.addfields({"title": dialogtitle, "message": dialogmessage})
setutility() 'located in source folder
end function
function setutility()
screen = CreateObject("roSGScreen")
screen.setMessagePort(m.port)
scene = screen.CreateScene("utilityScene")
screen.show()
while
msg = wait(0, m.port)
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed()
EXIT WHILE
end if
end if
end while
end function
<component name="utilityScene" extends="Scene" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd">
<interface>
<field id= "title" type = "string"/>
<field id= "message" type= "string" />
</interface>
<script type = "text/brightscript" >
<![CDATA[
sub init()
dialogNON()
end sub
sub dialogNON()
?"utilityScene"
m.background = m.top.findNode("Background")
example = m.top.findNode("instructLabel")
examplerect = example.boundingRect()
centerx = (1280 - examplerect.width) / 2
centery = (720 - examplerect.height) / 2
example.translation = [ centerx, centery ]
m.top.setFocus(true)
dialog = createObject("roSGNode", "Dialog")
dialog.title = m.top.title
dialog.optionsDialog = true
dialog.message = m.top.message
m.top.dialog = dialog
end sub
]]>
</script>
<children>
<Label
id = "instructLabel"
text = "" />
<Poster
id="Background"
width="1280"
height="720"
/>
</children>
</component>