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

Navigation: How to skip a row or menu item

Hi all,

I'm working on a menu item feature where an option may sometimes be locked due to device capabilities (e.g. doesn't support UHD content). While I'm able to show a lock icon next to the menu item when appropriate, I would like for the menu selector (using a MarkupList for this) to skip over that menu item when it's locked.

I've tried to set the menu item to focusable = false, but that doesn't seem to work as the user can still navigate over and select it.

Has anyone done something similar that they can share how it was accomplished?
0 Kudos
6 Replies
joetesta
Level 10

Re: Navigation: How to skip a row or menu item

you could observe the markupList's "itemFocused" field and when it becomes equal to your locked item, set jumpToItem to the next item.
You can probably use the field"itemUnfocused" so you know which direction the user is navigating and determine the appropriate item to jump to.
aspiring
0 Kudos
namlu
Level 7

Re: Navigation: How to skip a row or menu item

Hi @joetesta,

Thank you for your response.

Would you have to have some sample code for implementing a similiar feature? I've discussed this option w colleagues and implementation sounds quite challenging for something that shouldn't be.
0 Kudos
joetesta
Level 10

Re: Navigation: How to skip a row or menu item

dam it i wrote the code example then this forum told me to log in again and everything I wrote is lost Smiley Sad
aspiring
0 Kudos
namlu
Level 7

Re: Navigation: How to skip a row or menu item

Argh!!! So frustrating. Thanks @joetesta, I appreciate the effort.

If you do have the time, can you please try to repost?
0 Kudos
joetesta
Level 10

Re: Navigation: How to skip a row or menu item

yes sorry was meaning to do this last night before I fell asleep,
in init()

  m.markuplist = m.top.findnode("markupListID")
  m.markuplist.observeField("itemFocused", "focusChanged")
  m.lockedIndex = 3
end sub

sub focusChanged()
  itemFocused = m.markuplist.itemFocused
  if itemFocused = m.lockedindex
    'skip the locked item'
    nextItem = invalid
    if itemFocused > m.markuplist.itemUnfocused and itemFocused < m.markuplist.content.getChildCount() - 1
      nextItem = itemFocused + 1
    else if itemFocused < m.markuplist.itemUnfocused and itemFocused > 0
      nextItem = itemFocused - 1
    end if
    if nextItem <> invalid
      m.markuplist.jumpToItem = nextItem
    end if
  end if
end sub

You could add logic to bounce them back one if the locked item is at the end or beginning.  You could have an array of locked items and further complicate things.
This is just one way to do it, another way would be for each itemComponent to observe its own focusPercent and have a field to know if it's "locked" then react by setting it's parent's jumpToItem.  Don't know whether it'd be better ?
aspiring
0 Kudos
namlu
Level 7

Re: Navigation: How to skip a row or menu item

Awesome, thank you @joetesta! I'll give it a go and let you know how it goes. 

I'll have each item be able to react as the list of menu items could vary.
0 Kudos