I know this should be fairly simple but missing it. Trying to create a dialog that can be used from multiple locations in app by setting the title and message then calling the dialog. Not sure what I maybe missing. If gets in the dialogTask then get the error
Warnings occurred while spawning thread for Task component dialogTaskRegistry
spawning thread aborted because: channel exit or timeout waiting for render thread
So I guess it is not possible to create a reusable dialog that can have title and message set out side of the scene and called from anywhere in the app thru a task?
=================================================================
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.
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.
“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.
“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.
Ok forget the task. Just say I have function as below
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
Creates the scene. 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.
<?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.
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
“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
“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
I understand how calling the function and passing the info to the sub or function will work, but in this case it’s not possible. In the main.brs a busyspinner is initiated, from there several functions are executed and depending on results a dialog box may appear. Each dialog box is being created from a function that creates a scene for the individual dialog. I am attempting to eliminate the multiple functions that create the scenes and have one function that will create one scene. In the process of doing this a dialog title and dialog message will be set. The scene that creates the dialog is not located in the source folder.
main.brs
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
setutility.brs
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
utilityScene.xml this located in the components folder
<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>
The code works perfect except the title and message never get set. If I hard code the title and message into the appropriate locations dialog appears as expected. What is missing in setting the fields of the scene?