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

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

Perfect, just what I needed. Thanks!!