function onKeyEvent(key as string, press as boolean) as boolean
handled = false
if (press)
if(key = "options")
m.top.dialog = CreateObject("roSGNode", "Dialog")
m.top.dialog.title = "Settings"
m.top.dialog.message = "WOWOWOW"
buttons = ["First", "Second"]
m.top.dialog.buttons = buttons
m.top.dialog.ObserveField("buttonSelected", "DialogButtonSelected")
handled = true
end if
end if
return handled
end function
sub DialogButtonSelected()
if(m.top.dialog.buttonSelected = 0)
m.top.dialog = CreateObject("roSGNode", "Dialog")
m.top.dialog.title = "FIRST"
m.top.dialog.message = "FIRST"
else
m.top.dialog = CreateObject("roSGNode", "Dialog")
m.top.dialog.title = "Second"
m.top.dialog.message = "second"
end if
end sub
<?xml version="1.0" encoding="utf-8" ?>
<component name="MainScreen" extends="Scene" >
<script type="text/brightscript" uri="pkg:/components/Managers/FocusManager.brs" />
<children>
<Navigation id="MainNav" />
<CustomLabel id="csLbl" translation="[300, 200]" />
</children>
</component>
function init()
' The below two lines work as expected. Both returns the right nodes within the parent
m.lbl = m.top.findNode("csLbl")
m.mainNav = m.top.findNode("MainNav")
' Returns a node that is not existing in above component
m.mnNav = m.top.getChild(0)
' Returns a node that is called LayerRoot. What is LayerRoot ?
m.mnlbl = m.top.getChild(1)
m.top.SetFocus(true)
end function
Function http_post_from_string_with_timeout(val As String, seconds as Integer) as String
timeout% = 1000 * seconds
str = ""
m.Http.EnableFreshConnection(true) 'Don't reuse existing connections
print "url string" + val
if (m.Http.AsyncPostFromString(val))
event = wait(timeout%, m.Http.GetPort())
if type(event) = "roUrlEvent"
url_status = "Communication Response Code: " + str(event.GetResponseCode())
print "url_status " + url_status
print "event.GetFailureReason() " + event.GetFailureReason()
print "event.getString()" + event.GetString()
print "GetResponseHeaders " event.GetResponseHeaders()
if ( event.GetResponseCode() <> 200 ) then
else 'its a good response
str = event.GetString()
end if
elseif event = invalid
print "2"
m.Http.AsyncCancel()
else
print "3"
endif
endif
return str
End Function
m.connection.observeField("content", "sessionLookup")
m.connection.observeField("state", "stateLookup")
m.connection.functionName = "getContent"
m.connection.control = "RUN"
"edskitter" wrote:
What could be preventing the observers from never completing or triggering? Has anyone have any ideas why the Task is not allowing to proceed? I am at a standstill and don't know want else to try... Any help would be appreciated.
<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2015 Roku Corp. All Rights Reserved. **********-->
<component name="connection" extends="Task" >
<interface>
<field id="uri" type="string" />
<field id="content" type="node"/>
<field id="route" type="string" />
<field id="accountid" type="string" />
<field id="accountpassword" type="string" />
</interface>
<script type="text/brightscript" >
<![CDATA[
sub init()
'm.top.functionName = "getContent"
end sub
sub getContent()
http_headers = CreateObject("roAssociativeArray")
http_headers.Content_Type = "application/x-www-form-urlencoded"
post_string$ = "account_id=" + m.top.accountid + "&account_pin=" + m.top.accountpassword + "&app_version=1.0" + "&serial_number=" + getDeviceESN()
http = NewHttpJSON(m.top.uri, http_headers)
content = http.PostFromStringWithTimeout(post_string$, 30)
content = parseJSON(content)
print content
contentnode = createObject("RoSGNode","ContentNode")
contentnode.telcoid = content.telco.id
contentnode.url_sms = content.telco.url_sms
contentnode.support = content.telco.support
contentnode.account_id = content.user.account_id
contentnode.account_pin = content.user.account_pin
contentnode.account_state = content.user.account_state
m.top.content = contentnode
print "gets here fine"
end sub
sub stateLookup()
print "m.connection.state: " + m.connection.state
end sub
"edskitter" wrote:
Hello Endless,
Thank your for your response. I initially had the task component being initialized inside a custom node which extended Group. I then moved the Task to the main Scene and like you, received a run and stop, never a DONE status. So progress 😄
Saying that, what would you recommend to return so I can use the values application wide? Is extending the ContentNode the best choice in your opinion? I want to be able to work with standard values returned ( sessions, first name, last name etc.) from a login route.
How would you go about extending the ContentNode to use in the main scene?