Forum Discussion

Trader5050's avatar
10 years ago

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!

4 Replies

  • 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
  • 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.
  • 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
    ...