onAction problems
#1
Hi there,

Does onAction (self, action)

trap mouse and touch screen events? I appear to be having a few issues, I can trap keyboard presses fine.

Thanks for any help

Jason
Reply
#2
yes it does capture mouse and touchscreen as well.
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
So I have some code like this

ACTION_PREVIOUS_MENU = 10
ACTION_STOP = 13
ACTION_NAV_BACK = 92
ACTION_BACKSPACE = 110
ACTION_MOUSE_DOUBLE_CLICK = 103
ACTION_MOUSE_LONG_CLICK = 108
ACTION_TOUCH_TAP = 401
ACTION_TOUCH_LONGPRESS = 411

...

    def onAction(self, action):

        if action in (ACTION_PREVIOUS_MENU, 
                      ACTION_STOP,
                      ACTION_NAV_BACK,
                      ACTION_BACKSPACE,
                      ACTION_MOUSE_DOUBLE_CLICK,
                      ACTION_MOUSE_LONG_CLICK,
                      ACTION_TOUCH_TAP,
                      ACTION_TOUCH_LONGPRESS):
            self.isRunning = False
            monitor.waitForAbort(.2)
            self.close()


Which should detect the action and then go back to a previous screen...if there anything obviously wrong?
Reply
#4
i'm not so good at riddles, perhaps you can describe what your actual problem is?
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
#5
Smile 
Blush

Fair enough...let me explain.

I am actually using an add-on called "Surveillance Room", it has a mode in it that allows you to see multiple cameras in full screen mode so there are no buttons or anything. The add-on was not designed (in my view) to run on a  touchscreen device, it expected a keyboard to be connected so you could escape out of the full screen and back to the menu. What I am trying to go is trigger an event on the touchscreen so that I can replicate the escape key.

I have tried to contact the developer of this add on in another thread on this site but it looks like he has not logged in for a while so I thought I would try and sort this out myself. 

Any advice is appreciated, thanks for your time.
Reply
#6
cheer!

just spotted an issue in you code example above, you need to get the id of the action:
python:
if action.getId() in (ACTION_PREVIOUS_MENU, ...
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
#7
Thanks for the suggestion but it is still playing up, it detected a double click in the logs

log:
2019-03-08 11:12:52.276 T:1899224336   DEBUG: ProcessMouse: trying mouse action doubleclick

But it did not do anything with it ie back out

I previously increased the version of xbmc.python in addon.xml to
xml:
<import addon="xbmc.python" version="2.26.0"/>

This is very odd.
Reply
#8
I put some debug in the onAction (is it called a "class" now? We used to call them a function in our day) and print out the action.getID() codes, I managed to detect 511 (ACTION_GESTURE_SWIPE_LEFT) and use that.

It's odd that I cannot detect ACTION_TOUCH_TAP or ACTION_TOUCH_LONGPRESS but I have found an acceptable workaround.
Reply

Logout Mark Read Team Forum Stats Members Help
onAction problems0