Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
taylorcw
Level 7

MarkupGrid capturing focused item

I've been looking at this MarkupGrid example ( https://sdkdocs.roku.com/display/sdkdoc ... rid+Markup ).

    <MarkupGrid id = "exampleMarkupGrid" itemComponentName = "MarkupGridItem" ...... />

MarkupGrid uses   [ itemComponentName = "MarkupGridItem" ] to define the items. On markupgriditem.xml I added a <field id = "focusLabel" type="string" /> which holds a label value when the item comes into focus.

How can I observe this field from the parent scene holding the MarkupGrid? I tried the following, but was invalid.
m.markupgrid = m.top.findNode("exampleMarkupGrid")
m.markupgrid.observeField("focusLabel", "onFocusChange")  

On the same note, how to a determine when item is selected?

Thanks
0 Kudos
2 Replies
mco_dolo
Level 7

Re: MarkupGrid capturing focused item

m.markupGrid.observeField("itemFocused", "onItemFocused") 
m.markupGrid.observeField("itemSelected", "onItemSelected")

sub onItemFocused()
   focusedItem = m.markupGrid.content.getChild(m.markupGrid.itemFocused)
   // Do what you want with focused item
end sub

sub onItemSelected()
   selectedItem = m.markupGrid.content.getChild(m.markupGrid.itemSelected)
   // Do what you want with selected item
end sub


I hope this helps
0 Kudos
taylorcw
Level 7

Re: MarkupGrid capturing focused item

Perfect, just what I needed. Thanks!!
0 Kudos