Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 9

MarkupGrid capturing focused item

I've been looking at this MarkupGrid example ( ... 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 ="exampleMarkupGrid")
m.markupgrid.observeField("focusLabel", "onFocusChange")  

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

0 Kudos
2 Replies
Level 8

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
Level 9

Re: MarkupGrid capturing focused item

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