Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Trader5050
Newbie

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


... 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
4 REPLIES 4
RokuMarkn
Visitor

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.

--Mark
0 Kudos
belltown
Roku Guru

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
sjb64
Roku Guru

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

Re: list item vs button press

Thanks all for the replies! Good to have smart people to turn to.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.