Kodi Community Forum

Full Version: Python add-on for Custom GUI using WindowXML - how to get onFocusedItem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In a python add-on using WindowXML for custom GUI, I'm trying to access focused item (not selected) in a List control.

class GUI(xbmcgui.WindowXML):


   def onFocus(self, controlID):
       # This method gets triggered when my GUI focus (i.e. no Enter/OK pressed yet) moves to a particular control.
       curPanel = self.getControl(controlID).  # gets me the Panel that has focus.

      # how do I get the item that currently is focussed ?

     # curPanel.getSelectedItem() will return a value only when I hit OK on focused item.

I think the information I'm looking for (which item is focused) is available to the GUI because if we move focus to another control (not item in same control) and come back to this Panel, the last focused item on the Panel will again get focus. So somewhere in the GUI, it knows which item was focused.

Thanks in advance.
try if this works for you:
python:
position = curPanel.getSelectedPosition()
curItem = curPanel.getListItem(position)
Thanks Ronie.

I tried and it didn't work. I get the same error in logs when I try to reference any property of the curItem.

​​​​It seems like there is no way to access the focused item from Python Addons.