setFocus and setFocusId not passing focus to control
#1
On to my next issue...

My script has a WindowXML class. The xml file defines a List control with an id of 50 e.g.
Code:
<control type="list" id="50">

The control is hidden by default but can have its visibility toggled by pressing a key on the remote (which sets a window property).

My issue is that I can't get the control to focus when it becomes visible.

I've tried using:
Code:
self.setFocusId(50)
and
Code:
listbox = self.getControl(50)
self.setControl(listbox)
and neither is working (although 'listbox' is correctly set as the ControlList object).

I've tried debugging by printing the ID of the focussed control after the above lines and it confirms that the control does not have focus.

Am I doing something stupid?
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#2
(2017-02-19, 22:17)el_Paraguayo Wrote:
Code:
listbox = self.getControl(50)
self.setControl(listbox)
i assume that's a typo and not the actual python code you're using?

does your addon fill the list with content or is that done in xml?
does your addon toggle the visibility or is that done in xml?
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
You could try:
PHP Code:
xbmc.executebuiltin('Control.SetFocus(%d, %d)' % (500));
xbmc.executebuiltin('Control.Move(50, 0)');
self.getControl(50).selectItem(0); 

And just default the selection to index 0
Reply
#4
(2017-02-19, 22:39)ronie Wrote:
(2017-02-19, 22:17)el_Paraguayo Wrote:
Code:
listbox = self.getControl(50)
self.setControl(listbox)
i assume that's a typo and not the actual python code you're using?

does your addon fill the list with content or is that done in xml?
does your addon toggle the visibility or is that done in xml?
Ha. Yes, typo. Last line is meant to be setFocus.

Content is provided via python. XML has conditional visibility with the python code setting the relevant Window property.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#5
(2017-02-19, 22:39)Protocol-X Wrote: You could try:
PHP Code:
xbmc.executebuiltin('Control.SetFocus(%d, %d)' % (500));
xbmc.executebuiltin('Control.Move(50, 0)');
self.getControl(50).selectItem(0); 

And just default the selection to index 0
I can try that. But that seems an odd solution. Does that mean setFocus is broken in WindowXML? Seems unlikely.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#6
(2017-02-20, 00:50)el_Paraguayo Wrote: [XML has conditional visibility with the python code setting the relevant Window property.

perhaps that's a problem...
can you focus the list if you remove the visible condition in your xml file?

in case that does work, you can use either setVisible() or setVisibleCondition()
to control the visibility in python.
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
#7
I can add that to my list of things to try!

Thank you.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#8
(2017-02-20, 01:02)ronie Wrote:
(2017-02-20, 00:50)el_Paraguayo Wrote: [XML has conditional visibility with the python code setting the relevant Window property.

perhaps that's a problem...
can you focus the list if you remove the visible condition in your xml file?

in case that does work, you can use either setVisible() or setVisibleCondition()
to control the visibility in python.

Good shout, Ronie.

Using setVisibleCondition works here.

The weird little quirk now is that I have to press up a couple of times before it will let me scroll up or down in the list. That's quite minor compared to the list not working at all.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#9
(2017-02-20, 22:10)el_Paraguayo Wrote:
(2017-02-20, 01:02)ronie Wrote:
(2017-02-20, 00:50)el_Paraguayo Wrote: [XML has conditional visibility with the python code setting the relevant Window property.

perhaps that's a problem...
can you focus the list if you remove the visible condition in your xml file?

in case that does work, you can use either setVisible() or setVisibleCondition()
to control the visibility in python.

Good shout, Ronie.

Using setVisibleCondition works here.

The weird little quirk now is that I have to press up a couple of times before it will let me scroll up or down in the list. That's quite minor compared to the list not working at all.
I've managed to work out what the problem was. The setFocus wasn't actually working. I looked in the logs and I saw:
Code:
Control 50 in window 13000 has been asked to focus, but it can't
I needed to press up a few times so the control focus moved from a button to the list.

I then tried binding the setFocus to a different key to the one that toggled the visibility and that worked. So the problem was the setFocus command was happening too soon. Adding a small delay after triggering visibility fixed this.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply

Logout Mark Read Team Forum Stats Members Help
setFocus and setFocusId not passing focus to control0