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 7

list item vs button press

I'm using an roListScreen and I'm having trouble detecting button presses.

While searching online I see references to the function msg.GetIndex() displaying either the current list item's index OR being used to detect the button press. This doesn't make any sense as it can't be both.

For example, the following code works flawlessly:

if (msg.isListItemFocused())
screen.SetBreadcrumbText("Main Menu", content[msg.GetIndex()].Title)

... so that tells me that .getIndex() gets the current list item, NOT the button being pressed.

I need to be able to use the OK button, really.


EDIT: Ok, now I'm getting really confused because I'm "print"'ng the index number and it's different between button presses on the same list item...... so what's going on here? I need to get the button AND the list item separately!
0 Kudos
Level 8

Re: list item vs button press

On IsListItemSelected and IsListItemFocused, GetIndex returns the index of the item you're on. On IsRemoteKeyPressed, GetIndex returns the id of the button pressed. You can track IsListItemFocused events to know what item you're on when IsRemoteKeyPressed happens.

0 Kudos
Level 9

Re: list item vs button press

If the user selects a list item (by pressing the 'OK' key with the desired item highlighted), then you'll get an isListItemSelected roListItemEvent, with GetIndex() indicating which item was selected.

If the user focuses on a list item (as a result of pressing the up/down remote key), then you'll get an isListItemFocused roListItemEvent, with GetIndex() indicating the new focused item.

If the user presses a remote key that does NOT result in a list item being selected or focused (e.g. the left/right key), then you'll get an isRemoteKeyPressed roListItemEvent, with GetIndex() indicating which key was pressed.

You won't get more that one event per key press, so if the user selects an item by pressing the 'OK' key, you'll ONLY get the isListItemSelected event, NOT the isRemoteKeyPressed event.
0 Kudos
Level 10

Re: list item vs button press

Heres a snippet of code in my app that deals with this, hopefully it will help:

if Message.isListItemFocused() 
Record = Lists[Message.GetIndex()][Message.GetData()] ' gets the record from the gridview
end if
if Message.isRemoteKeyPressed() and Message.GetIndex()=10 and Record<>Invalid
ShowOptionsScreen(Record.Movie) ' Gets the movie field from the record previously set
0 Kudos
Level 7

Re: list item vs button press

Thanks all for the replies! Good to have smart people to turn to.
0 Kudos