Your Digital Media Has Never Looked So Good

 
btpoole
Topic Author
Posts: 321
Joined: Fri Feb 15, 2013 2:08 pm

Help on Dialog Box

Mon Jul 03, 2017 2:55 pm

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
=================================================================
Any help appreciated.

initial.brs

m.callDialog=CreateObject("RoSGNode", "dialogTask")
    m.callDialog.titles="TEST"
    m.callDialog.messages="TEST TEST"
    m.calldialog.control="RUN"


dialogTask.xml
<?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>


dialogScene.xml
<?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>

dialogs.brs
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
Topic Author
Posts: 321
Joined: Fri Feb 15, 2013 2:08 pm

Re: Help on Dialog Box

Thu Jul 06, 2017 5:03 am

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?
 
User avatar
RokuNB
Posts: 183
Joined: Fri Mar 31, 2017 2:22 pm

Re: Help on Dialog Box

Thu Jul 06, 2017 11:19 am

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
Topic Author
Posts: 321
Joined: Fri Feb 15, 2013 2:08 pm

Re: Help on Dialog Box

Thu Jul 06, 2017 11:46 am

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.

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.
 
User avatar
RokuNB
Posts: 183
Joined: Fri Mar 31, 2017 2:22 pm

Re: Help on Dialog Box

Thu Jul 06, 2017 1:30 pm

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
Topic Author
Posts: 321
Joined: Fri Feb 15, 2013 2:08 pm

Re: Help on Dialog Box

Thu Jul 06, 2017 4:47 pm

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.

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>

 
User avatar
RokuNB
Posts: 183
Joined: Fri Mar 31, 2017 2:22 pm

Re: Help on Dialog Box

Fri Jul 07, 2017 10:51 am

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
Topic Author
Posts: 321
Joined: Fri Feb 15, 2013 2:08 pm

Re: Help on Dialog Box

Sat Jul 08, 2017 7:43 am

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


Thank you RokuNB. 
 
btpoole
Topic Author
Posts: 321
Joined: Fri Feb 15, 2013 2:08 pm

Re: Help on Dialog Box

Thu Jul 13, 2017 6:37 am

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


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?

Who is online

Users browsing this forum: RokuNB and 4 guests