Stopping custom dialog from stealing focus and consuming keypresses
#1
First off - this is a repeat of a question I asked a while ago (see this thread: http://forum.kodi.tv/showthread.php?tid=212811)

I want to create a custom notification dialog for my addon (currently using WindowXMLDialog). The issue I'm facing is that as soon as I display the dialog, the dialog takes the focus so all key presses are trapped by that dialog (and current menus visibly lose focus).

I'm trying to replicate the behaviour of ordinary the ordinary notification dialog that doesn't trap key presses. Is this possible with python?

The solution presented in the earlier thread (adding a control to the current window) isn't really appropriate for what I want to do here as I need the ability to navigate freely without the dialog disappearing.

My code was as follows:
Code:
from time import sle*p

import xbmc
import xbmcgui
import xbmcaddon

__addon__ = xbmcaddon.Addon("script.my.addon.name")

class MyDialog(xbmcgui.WindowXMLDialog):
    def __init__(self, strXMLname, strFallbackPath, strDefaultName, forceFallback):
        # Changing the three variables passed won't change, anything
        # Doing strXMLname = "bah.xml" will not change anything.
        # don't put GUI sensitive stuff here (as the xml hasn't been read yet
        # Idea to initialize your variables here
        pass

    def onInit(self):
        # Put your List Populating code/ and GUI startup stuff here
        pass

    def onAction(self, action):
        # Same as normal python Windows.
        pass

    def onClick(self, controlID):
        """
        Notice: onClick not onControl
        Notice: it gives the ID of the control not the control object
        """
        pass

    def onFocus(self, controlID):
        pass

mydlg = MyDialog("customNotification.xml", __addon__.getAddonInfo('path'), "Default", "720p")
mydlg.show()
sle*p(5000)
mydlg.close()
NB for some weird reason, the forum blocks posts with the word s-l-e-e-p in them, so you'd need to replace the 2 asterisks with an e in the code.

My xml looks like this:
Code:
<window id="1142" type="dialog">

    <coordinates>
        <left>200</left>
        <top>100</top>
    </coordinates>

    <controls>

        <control type="label">
            <scroll>true</scroll>
            <autoscroll>true</autoscroll>
            <label>Testing Custom Notification</label>
            <visible>true</visible>
        </control>

    </controls>

</window>

If, instead, I run something simple like:
Code:
for x in range(10):
    xbmc.executebuiltin("Notification(Test, {})".format(str(x)))
then I can freely navigate while the notifications are being displayed. This is the behaviour I’d like to replicate.

Would be great to hear if there's any solution to this.


EDIT: I appreciate that there may be issues with this e.g. if the dialog doesn't trap keypresses then how do you close the dialog if your script doesn't? However, I hope my query is still valid.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#2
not possible as far as i know.
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
That was the conclusion I was coming to too.

Thanks.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#4
The only way I can seem to get it to work is by putting the xml file in the skin folder and then having a conditional visibility which I toggle from the python script.

If I do that then the dialog doesn't capture key presses.

This would, presumably, prevent me from putting the the addon in the official repository but I suspect I won't be doing that anyway (it's prone to break and I can't guarantee support). I can, however, put this out there as an option for users to do manually.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#5
Why not use standard notifications?
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#6
Because I need to customise the layout and using standard notifications means I'm tied to skin specific layouts.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#7
If you add the controls to the current window kodi is rendering through python it does not work for you? Something similar to the "ticker" you asked some time ago.
Cheers

Enviado do meu A0001 através de Tapatalk
Reply
#8
Not here, no.

I want to be able to navigate freely and have the custom notifications continue to display.

The ticker worked nicely, but needs to be added to each window.
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
Stopping custom dialog from stealing focus and consuming keypresses0