Trader5050
Newbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2015
10:50 AM
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:
... 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!
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!
4 REPLIES 4

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2015
11:37 AM
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
--Mark
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2015
11:50 AM
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.
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.
sjb64
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2015
01:39 PM
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
...
Trader5050
Newbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2015
02:11 PM
Re: list item vs button press
Thanks all for the replies! Good to have smart people to turn to.