I'm having a hard time getting a widget/component inside a custom component to get keypresses. I found that calling setFocus in the custom component's Init() doesn't fix this. Here's an example:
<component name="MyScreen" extends="Group">
<children>
<LabelList
id="Labels"
vertFocusAnimationStyle = "floatingFocus" >
<ContentNode role="content">
<ContentNode title="Label1" />
<ContentNode title="Label2" />
<ContentNode title="Label3" />
</ContentNode>
</LabelList>
</children>
</component>
I've tried a number of ways to get the keypresses to move the item selection on the LabelList content and the only thing that seems to work for me is the following hack.
Function Init()
m.LabelGroup = m.top.findNode("Labels")
m.setFocusOnce = false
End Function
Function onKeyEvent(key As String, press As Boolean)
if not m.setFocusOnce then
m.LabelGroup.setFocus(true)
m.setFocusOnce = true
endif
return false
End Function
After this, the focus stays on the LabelGroup and works as expected, but I have to call it once AFTER the init() for it to gain focus. What am i missing? Something regarding construction order or the nodes?