xml - Roku: How do I open a LabelList on a new screen? -
from brightscript, how open following labellist on new screen (not main screen/scene)?
<?xml version = "1.0" encoding = "utf-8" ?> <!--********** copyright 2016 roku corp. rights reserved. **********--> <component name = "labellistexample" extends = "group" initialfocus = "examplelabellist" > <script type = "text/brightscript" > <![cdata[ sub init() m.top.backgrounduri = "pkg:/images/rsgde_bg_hd.jpg" example = m.top.findnode("examplelabellist") examplerect = example.boundingrect() centerx = (1280 - examplerect.width) / 2 centery = (720 - examplerect.height) / 2 example.translation = [ centerx, centery ] m.top.setfocus(true) end sub ]]> </script> <children > <labellist id = "examplelabellist" > <contentnode role = "content" > <contentnode title = "renderable nodes" /> <contentnode title = "z-order/parent-child" /> <contentnode title = "animations" /> <contentnode title = "events , observers" /> <contentnode title = "on demand example" /> </contentnode> </labellist> </children> </component>
i think need understand scenegraph api little better understand how this. in main.brs file, roku screen created screen = createobject("rosgscreen")
, screen scene created scene = screen.createscene("scene")
. of custom components need added xml file of scene. in components folder create 2 separate files labellistexample.brs , labellistexample.xml. in labellistexample.brs add
sub init() m.top.backgrounduri = "pkg:/images/rsgde_bg_hd.jpg" example = m.top.findnode("examplelabellist") examplerect = example.boundingrect() centerx = (1280 - examplerect.width) / 2 centery = (720 - examplerect.height) / 2 example.translation = [ centerx, centery ] m.top.setfocus(true) end sub
in labellistexample.xml add this:
<?xml version="1.0" encoding="utf-8"?> <component name = "labellistexample" extends = "group" initialfocus = "examplelabellist" > <script type="text/brightscript" uri="pkg:/components/labellistexample.brs" /> <children > <labellist id = "examplelabellist" > <contentnode role = "content" > <contentnode title = "renderable nodes" /> <contentnode title = "z-order/parent-child" /> <contentnode title = "animations" /> <contentnode title = "events , observers" /> <contentnode title = "on demand example" /> </contentnode> </labellist> </children> </component>
now in scene.xml file child should add this:
<poster id="justposter" translation="[0, 0]" width="1280" height="720" /> <group id="customcomponentview" visible="false"> <examplelabellist id="customcomponent" /> </group> <group id="defaultview" visible= "true"> <label id="justlabel" color="0xffffff" translation="[50, 300]" wrap="true" width="1200" horizalign="center" text="hide me if can" opacity="0.5" font = "font:mediumboldsystemfont" /> </group>
so big question is: how go defaultview consist label customcomponentview have label list?simple really, need hide 1 , show other. need add onkeyevent() function in scene.brs file (in scene script if doing .xml). in scene init() initialize views , components first :
m.defaultview = m.top.findnode(defaultview) m.customcomponentview = m.top.findnode(customcomponentview) m.labellist = m.top.findnode(customcomponent) m.label = m.top.findnode(justlabel)
in onkeyevent() function when button "ok" pressed on remote, can control view visible with:
m.defaultview.visible = false m.customcomponentview = true
you need set focus when customcomponentview becomes visible with:
m.labellist.setfocus(true)
hope can continue this. check roku documentation find out more onkeyevent() function.
Comments
Post a Comment