Builtin function "SetFocus" starts count from top of visible section of list
#1
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?
Reply
#2
hmm...although it's actually coded like that in kodi, i would call it a bug.
https://github.com/xbmc/xbmc/blob/master...#L435-L442

i'm not sure why GetOffset() (first visible listitem) is added, imo it should be absolute, not relative.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
Thanks ronie, I'll post a ticket on trac shortly. Any one in particular I should cc in?
Reply
#4
me please Smile
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#5
Done: http://trac.kodi.tv/ticket/16557#ticket

Thanks again
Reply



Logout Mark Read Team Forum Stats Members Help
Builtin function "SetFocus" starts count from top of visible section of list0
This forum uses Lukasz Tkacz MyBB addons.