Closed chaklasiyanikunj closed 4 years ago
Any update regarding this?
There's nothing wrong with what you're trying to do. Observing fields on custom views from the scene level is supported. Without knowing more about what is happening inside your custom view, it's difficult to say what might be wrong.
I added Successfully MSG Component PosterGrid as Custom Component in SGD View as below.
MainScene.brs
sub Show(args as Object)
m.CustomPosterGridView = CreateObject("roSGNode", "ChannelIDPosterGrid")
m.CustomPosterGridView.observeFieldScoped("itemFocused", "OnPosterItemFocused")
m.top.ComponentController.CallFunc("show", {
view: m.CustomPosterGridView
})
end sub
sub OnPosterItemFocused(event as Object)
m.grid = event.GetRoSGNode()
?"MainScene :: OnPosterItemFocused :: m.grid :" m.grid
end sub
MainScene.xml
<component name="MainScene" extends="BaseScene">
<interface>
<field id="ItemFocused" type="integer" alwaysNotify="true" />
</interface>
</component>
ChannelIDPosterGrid.xml
<component name = "ChannelIDPosterGrid" extends = "Group" initialFocus = "examplePosterGrid" >
<interface>
<field id="ItemFocused" type="integer" alwaysNotify="true" />
</interface>
<script type = "text/brightscript" >
<![CDATA[
sub init()
m.top.backgroundURI = "pkg:/images/rsgde_bg_hd.jpg"
m.top.setFocus(true)
m.postergrid = m.top.findNode("examplePosterGrid")
m.postergrid.observeFieldScoped("itemFocused", "OnPosterItemFocused")
m.postergrid.translation = [ 130, 160 ]
m.readPosterGridTask = createObject("roSGNode", "ContentReader")
m.readPosterGridTask.contenturi = "http://www.sdktestinglab.com/Tutorial/content/rendergridps.xml"
m.readPosterGridTask.observeField("content", "showpostergrid")
m.readPosterGridTask.control = "RUN"
end sub
sub OnPosterItemFocused(event as Object)
m.grid = event.GetRoSGNode()
?"ChannelIDPosterGrid:: OnPosterItemFocused :: m.grid :" m.grid
end sub
sub showpostergrid()
m.postergrid.content = m.readPosterGridTask.content
end sub
]]>
</script>
<children>
<PosterGrid
id = "examplePosterGrid"
basePosterSize = "[ 512, 288 ]"
caption1NumLines = "1"
numColumns = "2"
numRows = "2"
itemSpacing = "[ 20, 20 ]" />
</children>
</component>
Content-Meta-Data :
<Content >
<item hdgridposterurl = "https://www.sdktestinglab.com/Tutorial/images/rectanglepg.jpg"
shortdescriptionline1 = "Rectangle Node"
x = "0" y = "0" />
...
</Content>
Any other Changes are required to enable ObserveField in MainScene?
I don't think the problem is with observing the field. I think your observer isn't firing because the value isn't changing. You are observing the itemFocused field on an instance of ChannelIDPosterGrid, but I don't see you ever changing that value in the component.
I'm sorry, But, I don't understand clearly. I also tried with only observing itemfocused field in MainScene. But no luck. How to change a value? You considered focus as value? In postergrid component, focus changed automatically right. Using up,down,right and left key.
Yes, the itemFocused field on the PosterGrid will change with focus because PosterGrid is a firmware component with logic built in for updating that value.
The itemFocused field you are observing from your scene does not belong to a PosterGrid. The field you are observing belongs to your ChannelIDPosterGrid component and I don't see any logic in that component for updating the value. That's a completely different field from the one on the PosterGrid. If you want the field on your component to mirror the field on the PosterGrid, you can make is an alias. There is more about that here: https://developer.roku.com/docs/references/scenegraph/xml-elements/interface.md
Ok Thank you, Now, For Focus, I'm Clearly Understand Clearly. It's Working fine, When I added alias in ChannelIDPosterGrid.xml like alias="examplePosterGrid.ItemFocused". But, It's a problem with the content. I tried to fetch the content using m.grid.content in MainScene. But no luck. I created another custom component For RowList. Here, Focus and content both are Working fine in MainScene using m.grid.content. and In PosterGrid Focus is Working fine. But, For a Content, It's Displayed "
I created a Custom Component using an 8_Custom Screen. Now, I tried to manage ObserveField in Component. It's successfully managed that component like below. And I stored Custom View content in a custom view, not stored and not updated in MainScene.
Custom Component:
But, I try to manage observeField in MainScene. But no luck. I also Refer GridView CreateNewOrUpdateGridNode() Function and something like applied a Custom View. But, also no luck. Here, My CustomView is Extends with Group and GridView Extends With SGDEXComponent. I also refer to this Example CustomGrid_ContentManager. In this example it's successfully managed. I also Put Interface Element in both XML File Custom View and MainScene. But no luck.
MainScene:
Is there any way to handle ObserveField in MainScene.brs. I also tried with the ObserveFieldScoped Field. But no luck. or Is there any Configuration required to handle this.