v18 Problem Setting Focus on a Control in a WindowXmlDialog
#1
It has come to my attention that "=11.0ptadding listitems to the built-in container will only work for windows and no longer for dialogs" under V18.
But I'm also finding out that I cannot set focus on a list control in a WindowXmlDialog.


I don't get an error but the focus never changes to the list control.
When I use web-pdb to debug my addon and run the function self.getFocusId(), the result comes back as zero instead of the ID of the list control.

It had been suggested that I do the following:
Python:

self.list = self.getControl(ListControl_ID)
self.list.setFocusId(ListControl_ID)

That suggestion does not work and in fact gives me the following error:
Quote:AttributeError: 'xbmcgui.ControlList' object has no attribute 'setFocusId'

So my question is, what procedure should I use under V18, to set focus on my list control?
Under V17.6, I have no problem setting focus on the list control.
Reply
#2
yup, my initial suggestion was incorrect.
it should be self.setFocusId(ListControl_ID)

in case it doesn't work, you may need to add some sleep between adding listitems to the container and setting focus.
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
@ronie
My code originally slept for 100 ms but I changed it to 1000 ms and it did not solve the problem.
I've even tried using Web-Pdb to halt execution to check whether or not focus has taken place inside the onAction function which I triggered by pressing the Down Arrow button on my remote.
Executing self.getFocusId() inside Web-Pdb returned zero as its value. I then manually ran the self.setFocusId(50) while in Web-Pdb followed by self.getFocusId() function and it still returned a value of zero.

I have another dialog that makes a button the default control and there's no problem with it under Leia.
I'm only having a focusing problem with the list control.

So as an experiment, I changed the default control to my dialog exit button (ID=20) in my xml file.
In my addon onInit function, I changed the code to self.setFocusId(20).
When I ran it, I saw the exit button highlighted. I then clicked the exit button so that Web-Pdb would halt execution in the onAction function.
I manually executed self.getFocusId() while in Web-Pdb and it returned the value 20 which is the ID of the exit button.

As a result of the above test, I'm convinced that we're dealing with a bug that prevents the list control from achieving focus.
Reply
#4
can you try what happens if you give your list another id? like 800 or something...
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
You Are The Man!
Thank you, it's working now.

Is there a list of control IDs we should not use in our Addons?
If so, can you provide a link to them.

Thanks
Reply
#6
perhaps 50 is the only one you can't use.. i'm not really sure.
there's a lot of id's used internally by kodi, mostly in the 1-100 range, but it should not really be an issue to re-use them in your addon as well.
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

Logout Mark Read Team Forum Stats Members Help
Problem Setting Focus on a Control in a WindowXmlDialog0