2016-02-03, 17:56
Hi all,
I have a list of items sorted ascending by name in a kodi plugin. When using the in built function SetFocus the position where focus is given is calculated from the top of the visible portion of the list, not the beginning of the list. Eg, a list of 26 items, each item a letter of the alphabet. I scroll through the list so 'I' is on top of the visible portion of the list and use SetFocus to gain focus on item 3, focus will be on "L", not "D". If "K" is highlighted, but "I" is at the top of the visible portion, focus is given to "L".
Jarvis RC2 on Windows. Code:
Is this the correct behavior? If so, is there anyway to make SetFocus start from the first list item in the container and not the top of the visible portion of the list?
I have a list of items sorted ascending by name in a kodi plugin. When using the in built function SetFocus the position where focus is given is calculated from the top of the visible portion of the list, not the beginning of the list. Eg, a list of 26 items, each item a letter of the alphabet. I scroll through the list so 'I' is on top of the visible portion of the list and use SetFocus to gain focus on item 3, focus will be on "L", not "D". If "K" is highlighted, but "I" is at the top of the visible portion, focus is given to "L".
Jarvis RC2 on Windows. Code:
Code:
total_list_items = int(xbmc.getInfoLabel('Container(id).NumItems'))
random_list_item = random.randint(1, total_list_items)
win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
cid = win.getFocusId()
xbmc.executebuiltin('SetFocus(%s, %s)' % (cid, random_list_item))
Is this the correct behavior? If so, is there anyway to make SetFocus start from the first list item in the container and not the top of the visible portion of the list?