Your Digital Media Has Never Looked So Good

 
Trader5050
Topic Author
Posts: 13
Joined: Wed Sep 16, 2015 8:12 pm

list item vs button press

Thu Sep 17, 2015 10:50 am

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!
 
User avatar
RokuMarkn
Roku Engineering
Posts: 1581
Joined: Mon Jun 09, 2008 9:20 am

Re: list item vs button press

Thu Sep 17, 2015 11:37 am

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
 
belltown
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: list item vs button press

Thu Sep 17, 2015 11:50 am

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.
https://github.com/belltown/
 
sjb64
Posts: 108
Joined: Thu Apr 16, 2015 1:13 pm
Location: Memphis, TN

Re: list item vs button press

Thu Sep 17, 2015 1:39 pm

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
     ...
FlixRaider channel
 
Trader5050
Topic Author
Posts: 13
Joined: Wed Sep 16, 2015 8:12 pm

Re: list item vs button press

Mon Sep 21, 2015 2:11 pm

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

Who is online

Users browsing this forum: No registered users and 10 guests