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: 
btpoole
Level 7

markupgrid and markuplist scroll together

Is it possible to "bind" the rows of a markupgrid to markuplist so that the markupgrid scrolls along with the markuplist? Thought maybe setting the markupgrid.jumptoitem equal to the position (itemfocused) of the markuplist would work but doesn't seem to work.  Using the example markuplist in the sdk I had modified as shown below. The index value is set but when remote down is pressed it doesn't enter that part of the else if.  Does the grid have to have focus to scroll?
Thanks


function onFocusChanged() as void
    print "Focus on item: " + stri(m.simpleMarkupList.itemFocused)
    print "Focus on item: " + stri(m.simpleMarkupList.itemUnfocused) + " lost"
    index=m.simpleMarkupList.itemFocused
  ?"INDEX  "index
end function

function onKeyEvent(key as String, press as Boolean) as Boolean
    handled = false
    if (m.simpleMarkupList.hasFocus() = true) and (key = "right") and (press=true)
   m.simpleMarkupGrid.setFocus(true)
  m.simpleMarkupList.setFocus(false)
      ?"key "key
   handled = true
else if (m.simpleMarkupList.hasFocus() = true) and (key = "down") and (press=true)
      ?"key "key
       m.simpleMarkupGrid.jumptoItem=index
  else if (m.simpleMarkupGrid.hasFocus() = true) and (key = "left") and (press=true)
 m.simpleMarkupGrid.setFocus(false)
m.simpleMarkupList.setFocus(true)
   handled = true
endif
    return handled
end function


 
0 Kudos
3 Replies
Highlighted
monkeysource
Level 7

Re: markupgrid and markuplist scroll together

I would look at the focusPercent on the MarkupGrid node. You can watch this, and if it goes above 0 for a grid node then call animateToItem on your markupList to get that to start animating to the same item. 

It will take a little communication between the two, but should be possible. 

See https://sdkdocs.roku.com/display/sdkdoc/MarkupGrid and look at the focusPercent documentation. 
0 Kudos
btpoole
Level 7

Re: markupgrid and markuplist scroll together

Thanks for the advice, I'll take look at that.
0 Kudos
btpoole
Level 7

Re: markupgrid and markuplist scroll together

This may help somebody else in the future, also somebody else may know of a better way. To get my grid to scroll with the list I done something like this. Note the line where I am multiplying the m.simpleMarkupList  * 4, the "4" is the number of columns I have in the grid.

function onFocusChanged() as void
    print "Focus on item: " + stri(m.simpleMarkupList.itemFocused)
    print "Focus on item: " + stri(m.simpleMarkupList.itemUnfocused) + " lost"
     index=m.simpleMarkupList.itemFocused * 4
     m.simpleMarkupGrid.jumpToItem= index
  end function
0 Kudos