Posts: 1,109
Joined: Feb 2011
Reputation:
39
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.
Posts: 180
Joined: Aug 2016
You should be able to use
PHP Code:
def onAction(self, action):
if action.getId() in (xbmcgui.ACTION_PREVIOUS_MENU, xbmcgui.SOME_OTHER_ACTION)
DO SOMETHING
return;
Posts: 1,109
Joined: Feb 2011
Reputation:
39
Thanks. Is the return bit the key thing here?
I thought I'd done that already but will check tonight.
Posts: 180
Joined: Aug 2016
(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(self, action);
Posts: 180
Joined: Aug 2016
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
Posts: 1,109
Joined: Feb 2011
Reputation:
39
That looks pretty neat. I'll try it out.
Posts: 1,109
Joined: Feb 2011
Reputation:
39
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.
Posts: 180
Joined: Aug 2016
(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.
Posts: 1,109
Joined: Feb 2011
Reputation:
39
OK. Thank you.
Also, FYI script.module.actionhandler is deprecated and is now part of script.module.kodi65.