Kodi Community Forum

Full Version: Handling remote keypresses while addon script is running
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have a custom plugin that uses a custom window to display slide presentations with linked audio files.

My question is - how do I handle remote key presses while my script is running to allow the user to control the presentation?

Basically, I need to create custom Actions that I can add to the remote.xml keymap file for my custom window. Using standard Actions are not a problem.

I have experimented with mapping a custom script to the keys via the RunScript() function, but then I have don't have access to the variables of my original addon script.

Is there any other way that my addon script can be notified that a remote key has been pressed, and what the key is, while the addon script is running?
After further research, I came to the conclusion I need to override the onAction() method of my custom window.
This is my code:

Code:
class myWindow(xbmcgui.Window):

      logging.info('class created')
      
      def onAction(self, action):

           logging.info('myClass action' + str(action) )
           xbmcgui.Dialog().ok('myWindow action', str(action))

           xbmcgui.Window.onAction(action)
        


window = myWindow()
....
....

If have added the logging statements and the popup dialog window to try and debug the problem.

The first log statement is executed and logged.

While my custom window is displayed, I pressed a number of remote keys the key presses are logged in the debug log.

The second log statement and the popup dialog are never executed (nothing is logged) for the key presses
My conclusion is that the actions are never send to my window.

In the remote.xml keycap, I have made sure that the keys I am testing with, are defined in the <global> <remote> section of the file.

What am I doing wrong here?
After experimentation, I have concluded that the only way to receive actions in a custom window created via xbmcgui.WindowXML(), is to make the window modal.

The problem with showing the window using .doModal(), is that the execution of the script stops, which is not what I want.

If you show the window via .show(), the window does not receive any actions.

Is this correct?

How do I get Kodi to send actions to my custom window without showing it as a modal window?