Your Digital Media Has Never Looked So Good

 
taylorcw
Topic Author
Posts: 9
Joined: Mon Jan 18, 2016 7:41 pm

MarkupGrid capturing focused item

Wed Nov 08, 2017 8:55 pm

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
 
mco_dolo
Posts: 3
Joined: Wed Nov 01, 2017 2:27 pm

Re: MarkupGrid capturing focused item

Wed Nov 08, 2017 9:04 pm

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
 
taylorcw
Topic Author
Posts: 9
Joined: Mon Jan 18, 2016 7:41 pm

Re: MarkupGrid capturing focused item

Sat Nov 11, 2017 6:00 am

Perfect, just what I needed. Thanks!!

Who is online

Users browsing this forum: No registered users and 7 guests