joycewang
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2016
06:39 PM
onKeyEvent cannot recognize custom component
Hi, I'm new to Scene Graph xml. I meet an problem recently, that I create a custom xml component "CustomButton". It works good when I try to create it in init() function, but it cannot be created in onKeyEvent() function. Here is the sample code:
Anyone could help me? Thanks in advance!
<?xml version="1.0" encoding="utf-8" ?>
<component name="CustomButton" extends="Group">
<children>
<Poster id="background" />
<Poster id="focusBox" />
<Label id="text" />
</children>
</component>
<?xml version="1.0" encoding="utf-8" ?>
<component name="channelListScreen" extends="Group">
<script type="text/brightscript">
<![CDATA[
function init() as Void
a = createObject("roSGNode", "CustomButton")
? a ' a is a roSGNode here
end function
function onKeyEvent(key as String, press as Boolean) as Boolean
a = createObject("roSGNode", "CustomButton")
? a ' a is Invalid here
end function
]]>
</script>
<children>
<Label text="Channel List Screen"/>
</children>
</component>
Anyone could help me? Thanks in advance!
5 REPLIES 5
BCVatOVG
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2016
04:42 PM
Re: onKeyEvent cannot recognize custom component
I am running into this exact same problem. Have you found a solution or workaround?
Dhir_Pratap
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2016
02:23 AM
Re: onKeyEvent cannot recognize custom component
I can also confirm this issue. Cannot create custom component in onKey Event
joycewang
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2016
01:50 AM
Re: onKeyEvent cannot recognize custom component
I'm now creating custom components dynamically in code, based on basic renderable nodes.
However there's a drawback, there is no onKeyEvent in each component, and I cannot use the feature of focus chain provided by Scene Graph XML. I have to create my own focus mananger to handle the key event and navigation.
Please suggest if you have better solutions.
function createCustomButton(opts as Object) as Object
customButton = {
node: Invalid
setup: function(opts as Object) as Void
m.node = createObject("roSGNode", "Group")
m.node.appendChild(createPoster().node)
m.node.appendChild(createPoster().node)
m.node.appendChild(createLabel().node)
end function
}
customButton.setup(opts as Object)
return customButton
end function
However there's a drawback, there is no onKeyEvent in each component, and I cannot use the feature of focus chain provided by Scene Graph XML. I have to create my own focus mananger to handle the key event and navigation.
Please suggest if you have better solutions.
brybott
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2016
04:57 PM
Re: onKeyEvent cannot recognize custom component
Yes, I also can confirm this doesn't work. Another drawback to joycewang's approach is that you can't use any custom interface fields.
In addition to not working with onKeyEvent, custom components also return invalid when created within node.observeField() callback functions.
It would make me happy if Roku would indicate if this is something on their radar of things to update/fix.
In addition to not working with onKeyEvent, custom components also return invalid when created within node.observeField() callback functions.
It would make me happy if Roku would indicate if this is something on their radar of things to update/fix.
brybott
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2016
11:42 AM
Re: onKeyEvent cannot recognize custom component
My device updated to 7.1 firmware today, and this doesn't seem to be a problem anymore after preliminary testing. 😄