"Control (...) has been asked to focus, but it can't"
#1
I want to reuse the DialogSelect window without having to go in and recreate the full XML. I just want to hook into the "onAction" and "onClick" handlers to do some other things.

This is the smallest example I could get of the problem: it opens the dialog and then you can't focus on the list (control ID #3 of DialogSelect.xml) at all. Why is that?
How can I make it so the list is focusable and behaves as if I just called with xbmcgui.Dialog().select() ?

python:

# -*- coding: utf-8 -*-
import xbmc
import xbmcgui


class CustomDialogSelect(xbmcgui.WindowXMLDialog):
    def __init__(self, *args, **kwargs):
        xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)        

    def onInit(self):
        self.getControl(3).addItems(('Item 1', 'Item 2', 'Item 3'))
        self.getControl(5).setLabel('My Label')
        
    def onClick(self, controlId):
        xbmc.log(str(controlId), xbmc.LOGNOTICE)
        self.close()
        

if __name__ == '__main__':    
    ui = CustomDialogSelect('DialogSelect.xml', '') # Use the DialogSelect.xml from the built-in skin, not the add-on.
    ui.doModal()
    del ui
Reply
#2
(2019-03-30, 16:38)doko-desuka Wrote: I want to reuse the DialogSelect window without having to go in and recreate the full XML. I just want to hook into the "onAction" and "onClick" handlers to do some other things.

This is the smallest example I could get of the problem: it opens the dialog and then you can't focus on the list (control ID #3 of DialogSelect.xml) at all. Why is that?
How can I make it so the list is focusable and behaves as if I just called with xbmcgui.Dialog().select() ?

...

Set focus on the control at the end of OnInit().

You won't be able to avoid the error in the log, but it will work as expected. I don't think this window was designed to be used like this, it's more of a happy accident that it does.
Reply
#3
(2019-03-30, 17:04)rmrector Wrote: Set focus on the control at the end of OnInit().

You won't be able to avoid the error in the log, but it will work as expected. I don't think this window was designed to be used like this, it's more of a happy accident that it does. 

Hi rmrector, thanks for the suggestion.
I also found this a few minutes ago: https://forum.kodi.tv/showthread.php?tid...pid2424845
According to @phil65 , if you enclose the two lists in another group, like <control type="group" id="666"> </control>, the error goes away. You do this in a copy of "DialogSelect.xml" which should be placed in "plugin.video.youraddon/resources/skins/Default/720p"
Reply

Logout Mark Read Team Forum Stats Members Help
"Control (...) has been asked to focus, but it can't"0