Kodi Community Forum
Builtin function "SetFocus" starts count from top of visible section of list - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Builtin function "SetFocus" starts count from top of visible section of list (/showthread.php?tid=258722)



Builtin function "SetFocus" starts count from top of visible section of list - teeedubb - 2016-02-03

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:
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?


RE: Builtin function "SetFocus" starts count from top of visible section of ... - ronie - 2016-02-04

hmm...although it's actually coded like that in kodi, i would call it a bug.
https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/GUIBaseContainer.cpp#L435-L442

i'm not sure why GetOffset() (first visible listitem) is added, imo it should be absolute, not relative.


RE: Builtin function "SetFocus" starts count from top of visible section of list - teeedubb - 2016-02-04

Thanks ronie, I'll post a ticket on trac shortly. Any one in particular I should cc in?


RE: Builtin function "SetFocus" starts count from top of visible section of ... - ronie - 2016-02-04

me please Smile


RE: Builtin function "SetFocus" starts count from top of visible section of list - teeedubb - 2016-02-04

Done: http://trac.kodi.tv/ticket/16557#ticket

Thanks again