Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
taylorcw
Binge Watcher

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 2
mco_dolo
Visitor

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
Binge Watcher

Re: MarkupGrid capturing focused item

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