Catching key presses via onAction works for doModal(), but not for show()?!?
#1
I'm at a loss. While developing PlexKodiConnect, if I use show() like this:
python:

class TestWindow(xbmcgui.Window):
    def onAction(self, action):
        LOG.debug('onAction: %s', action)

window = TestWindow()
window.show()
time.sleep(10)
window.close()
any key presses are NOT captured by the add-on.

On the other hand, using doModal() works as expected:
python:

class TestWindow(xbmcgui.Window):
    def onAction(self, action):
        LOG.debug('onAction: %s', action)

window = TestWindow()
window.doModal()
and key presses are all logged. 

I'm trying to re-write some code from Plex for Kodi, where show() works just fine. What am I missing?

Edit: Link to working show(): Plex for Kodi
Reply
#2
This is expected behavior. show() only displays a window without starting the event loop so no UI events like key presses or mouse clicks are being caught .
Reply
#3
OK, thanks. The Kodi documentation is not clear on this.

Must have overlooked some implementation detail with Plex for Kodi - because they managed to make it work, somehow
Reply
#4
(2018-07-14, 22:50)Croneter Wrote: Must have overlooked some implementation detail with Plex for Kodi - because they managed to make it work, somehow

It is possible only if a secondary window (displayed with .show() ) is controlled by a primary modal window that receives all UI events. This primary window might not have any visible elements but still it must be started with .doModal(). No modal - no UI events: plain and simple.
Reply
#5
(2018-07-16, 19:45)Roman_V_M Wrote:
(2018-07-14, 22:50)Croneter Wrote: Must have overlooked some implementation detail with Plex for Kodi - because they managed to make it work, somehow

It is possible only if a secondary window (displayed with .show() ) is controlled by a primary modal window that receives all UI events. This primary window might not have any visible elements but still it must be started with .doModal(). No modal - no UI events: plain and simple.  
This works! 

For anyone still having issues: the background .doModal() dialog CANNOT be put to sleep with 
python:
time.sleep(0.1)
. You need to make sure to use 
python:
xbmc.sleep(100)
. Took me ages to pin that one down  Confused
Reply

Logout Mark Read Team Forum Stats Members Help
Catching key presses via onAction works for doModal(), but not for show()?!?0