I'm trying to simple navigation. And I tried more than one way to open another screen.
- Hide/show concept (But It's working only single File).
- Using View Stack (But Still Not Working)
- Using tag and inside the tag to call another file. (But Its error has given Interface not a member of BrightScript Component)
- Using the same tag and inside the tag to call another file. (But It does not fetch the value from another file).
Here My First File Write a code to First Screen
Main.brs
screen = CreateObject("roSGScreen") 'one Application only once roSGScreen
m.port = CreateObject("roMessagePort")
screen.setMessagePort(m.port)
scene = screen.CreateScene("WisePanel") 'Here the First screen component name
screen.show()
PanelSet.xml
<?xml version="1.0" encoding="UTF-8"?>
<component name="WisePanel" extends="Scene">
<script type="text/brightscript" uri="pkg:/components/PanelSet.brs" />
<Group id="FirstScreen" >
<Label
id = "lbfirstscreen"
font="font:LargeBoldSystemFont"
text = "This is the first Screen"
translation = "[200,250]" />
</Group>
</component>
Here the .brs file in the key event set to open another screen(click option key and open a new screen)
PanelSet.brs
sub init()
m.FirstScreenLabel = m.top.findNode("lbfirstscreen")
end sub
function onKeyEvent(key as String, press as Boolean) as Boolean
handled = false
if press then
if key="options" then
' Here the write a Logic
keyboard= CreateObject("roSGNode", "KeyboardDialog")
?"call keyevent Fucntion"
'here show function to give a error
m.top.ComponentController.CallFunc("show", {
view: keyboard
})
end if
end if
end function
My second screen XML and brs both in single file File is
keyboarddialogscene.xml
<?xml version = "1.0" encoding = "utf-8" ?>
<component name = "KeyboardDialog" extends = "Group" >
<script type = "text/brightscript" >
<![CDATA[
sub init()
m.SecondScreenLabel = m.top.findNode("lblsecondscreen")
end sub
]]>
</script>
<children >
<Group id="SecondScreen" >
<Label
id = "lblsecondscreen"
font="font:LargeBoldSystemFont"
text = "This is the second Screen"
translation = "[200,250]" />
</Group>
</children>
</component>
I try to Click in Remote Option key then I display a Label on second screen File anyone knows the issue.
I used your code, I was able to make it work, however, I made some adjustments.
I think your issue with the code just as you have it right now, is a "scope" issue, let me explain a little bit.
You are trying to call "m.top.ComponentController" within you panelset.brs file but "ComponentController" is not a field on the panelset component, in that scope you can only access the fields on the panelset interface.
So you have two options:
1 - On your panelSet.brs instead of calling "m.top.ComponentController" change it for "m.top.getScene().ComponentController".
2 - Create a field within your on your wisePanel.xml, add a listener to that field where you create the WisePanel component, in that scope, you'll be able to m.top.componentController.
Note: I used the setup_and_helloworld link example of the Roku Dev with your files.
Doc