Can WindowXML consume actions?
#1
I have a python script which displays a window via WindowXML.

I'd like to capture various key presses to trigger certain actions. However, if I listen for, say, ACTION_VOLUME_UP, I still get Kodi adjusting its own volume.

Is there a way for my window to consume the action so Kodi's default behaviours are ignored while my window is open?

Sorry if I've explained that badly.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#2
You should be able to use

PHP Code:
def onAction(selfaction):

        if 
action.getId() in (xbmcgui.ACTION_PREVIOUS_MENUxbmcgui.SOME_OTHER_ACTION)
            DO 
SOMETHING
            
return; 
Reply
#3
Thanks. Is the return bit the key thing here?

I thought I'd done that already but will check tonight.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#4
(2017-02-15, 12:50)el_Paraguayo Wrote: Thanks. Is the return bit the key thing here?

I thought I'd done that already but will check tonight.

I have had no issues without return, but others have so I'd say keep it. Also you should add an else and put the following so that default actions still work, unless you don't want any default actions like exit, previous window ect.


PHP Code:
else:
            
xbmcgui.WindowXML.onAction(selfaction); 
Reply
#5
Unfortunately, it doesn't seem to work. My onAction method looks like this:
Code:
def onAction(self, action):

        act = action.getId()
        
        if act in CLOSING_ACTION:
            debug("Action {} is a closing action. Closing window.".format(act))
            self.close()
        elif act == ACTION_VOLUME_UP:
            debug("Volume Up!")
            return
        else:
            debug("Unhandled action ID: {}".format(action.getId()))

        return
Pressing F10 does create the debug log entries but I also get Kodi's volume increasing.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#6
Take a look at this script. Make sure you are using the correct action ids. Also you can try using this script. I have no experience with it my self though.
https://github.com/phil65/script.module....Handler.py
Reply
#7
That looks pretty neat. I'll try it out.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#8
It is very neat but it doesn't fix the problem unfortunately. Ideally I'd want the volume up and down actions not to trigger the kodi volume change. If that's not possible then I can look at using other actions to get my end result.

I'll still use the actionhandler module though as it'll make my code a bit neater.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#9
(2017-02-16, 20:54)el_Paraguayo Wrote: It is very neat but it doesn't fix the problem unfortunately. Ideally I'd want the volume up and down actions not to trigger the kodi volume change. If that's not possible then I can look at using other actions to get my end result.

I'll still use the actionhandler module though as it'll make my code a bit neater.

I'll see what I can dig up when I get home. You may need to override onclick it might be getting triggered there too.
Reply
#10
OK. Thank you.

Also, FYI script.module.actionhandler is deprecated and is now part of script.module.kodi65.
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
Can WindowXML consume actions?0