Hi,
I'm trying to structure my app so that each screen is in its own Group so that I can toggle visibility for each screen from the top level Scene.
However somehow a button on a [child] screen despite having focus, does not respond to click events.
If I have a button that's setup the same way directly as a child of the top level Scene, it works as expected.
What am I missing? Is Group not the right way to cluster / group a screen's elements? Is there something else I need to do to ensure elements in the child screen receive input events?
Here is the source code that demonstrates the issue:
EntryScreen.xml
<?xml version="1.0" encoding="utf-8" ?>
<component name="EntryScreen" extends="Scene">
<children>
<ChildScreen
id="ChildScreen"
visible="false"/>
<Button
id="TopLevelButton"
text="Top Level Button"
textFont="font:LargeBoldSystemFont"
focusedTextFont="font:LargeBoldSystemFont"
translation="[700,840]"
visible = "true"/>
</children>
<interface>
</interface>
<script type="text/brightscript" uri="pkg:/components/EntryScreen.brs"/>
</component>
EntryScreen.brs
sub init()
print "init top level scene/screen"
m.Button = m.top.findNode("TopLevelButton")
m.Button.observeField("buttonSelected", "onButtonPress")
m.Button.setFocus(true)
end sub
sub onButtonPress(event as object)
print "Top Level Button Clicked"
end sub
ChildScreen.xml
<?xml version="1.0" encoding="utf-8" ?>
<component name="ChildScreen" extends="Group">
<children>
<Button
id="ChildLevelButton"
text="Child Level Button"
textFont="font:LargeBoldSystemFont"
focusedTextFont="font:LargeBoldSystemFont"
translation="[700,840]"/>
</children>
<interface>
</interface>
<script type="text/brightscript" uri="pkg:/components/ChildScreen.brs"/>
</component>
ChildScreen.brs
sub init()
print "init child screen"
m.Button = m.top.findNode("ChildLevelButton")
m.Button.observeField("buttonSelected", "onChildButtonPressed")
m.Button.text = "Child Level Button Changed From Code"
m.Button.setFocus(true)
end sub
sub onChildButtonPressed(event as object)
print "Child Level Button Clicked"
end sub
To see the different behavior, I toggle the visible flag on the children in EntryScreen.xml
Any help on this is much appreciated.
Cheers,
Thorben