Posts: 180
Joined: Aug 2016
What are you doubleclicking on? If an object does not support doubleclicking it will never fire. For example if you try to capture a doubleclick on a button it will never fire. What you could do is add a 1 second timer to the onclick if it is a button and have a boolean that resets if the 1 second expires, otherwise if it is not expired the 2nd click can be captured as a doubleclick using your own logic.
Posts: 56
Joined: Jul 2015
Reputation:
0
I could try that. But explain why a button doesn't support a doubleclick? The doubeclick is technically coming from WindowXMLDialog. It then should tell you what control you doubleclicked on. This is how onclick works.
The Button control itself does not have an onclick method, the Window does. The Window then reports what control the onClick took place.
According to the docs WindowXMLDialog supports both onClick and onDoubleClick. So, I would assume it should fire.
onClick(...)
onClick(self, int controlId)--onClick method.
This method will receive all click events that the main program will send
to this window.
onDoubleClick(...)
onDoubleClick(self, int controlId)--onClick method.
This method will receive all double click events that the main program will send
to this window.
Posts: 180
Joined: Aug 2016
You would need to ask a one of the Kodi team members. Buttons themselves do Support onclick so I assume it is a built in check. It makes sense, since by design in any application a button is always a user click not a doubleclick. Don't get me wrong obviously I needed a doubleclick for reasons but in general most won't expect a button to be doubleclicked.
Posts: 56
Joined: Jul 2015
Reputation:
0
Perhaps one will read this thread and give some input. Otherwise, I will implement my own logic, like you recommended. Thanks!
Posts: 180
Joined: Aug 2016
(2016-12-22, 17:27)jgauthier Wrote: Perhaps one will read this thread and give some input. Otherwise, I will implement my own logic, like you recommended. Thanks!
You might want to use less than a second. I think mine was 0.2 before reseting. If time ran out and it resets then it performs click action, if time it has not reset when a user clicks, it resets, ignores click and performs a doubleclick. Not the best implementation bit it worked for my needs.
Posts: 56
Joined: Jul 2015
Reputation:
0
Can you share your double click logic?
Posts: 180
Joined: Aug 2016
(2016-12-22, 20:54)jgauthier Wrote: Can you share your double click logic?
I can , but it will be tomorrow most likely as I'm out at the office currently.
Posts: 180
Joined: Aug 2016
It is far from the best solution, but it does the trick
PHP Code:
.
def onClick(self, controlID):
from threading import Timer;
#add some kind of controlID check
if self.clicked:
self.clicked = False;
#do doubleclick things here
else:
self.clicked = True;
t = Timer(0.15, self.doxyz);
t.start();
def doxyz(self):
if self.clicked:
self.clicked = False;
#do single click things
Posts: 180
Joined: Aug 2016
2016-12-23, 17:22
(This post was last modified: 2016-12-23, 17:26 by User 342716.)
(2016-12-23, 13:30)Taifxx Wrote: (2016-12-23, 05:03)Protocol-X Wrote: It is far from the best solution, but it does the trick
Your code don't work with all controls. The problem is that event onClick interpretate real double click (fast double click) as single click and don't called twice.
You need use onAction method for catching all click events.
For example:
Code:
def __init__(self):
self.timeout = 1.0 # or 0.5 as you wish
self.clicker = 0
self.target_control = 200 # control id
def onAction(self, action):
action_Id = action.getId()
control_Id = self.getFocusId()
# ACTION_MOUSE_LEFT_CLICK (run self.clicksEvents only if no clicks)
if action_Id == 100 and self.clicker == 0 and control_Id == self.target_control:
t = threading.Timer(self.timeout, self.clicksEvents)
t.start()
# ACTION_MOUSE_LEFT_CLICK or ACTION_MOUSE_DOUBLE_CLICK (clicks count +1)
if action_Id in [103, 100] and control_Id == self.target_control:
self.clicker += 1
self.xbmcgui.WindowXMLDialog.onAction(action)
def clicksEvents(self):
if self.clicker < 2:
# Single click action
pass
else:
# Multi click action
pass
self.clicker = 0
Much better. Mine was only for testing purposes, but I will use this idea in the future if i need such as task again.
This is what i ended up doing in my final code.
PHP Code:
.
def onAction(self, action):
EXIT_CLICK = (
xbmcgui.ACTION_MOUSE_DOUBLE_CLICK,
xbmcgui.ACTION_MOUSE_LONG_CLICK,
xbmcgui.ACTION_TOUCH_LONGPRESS
);
actionID = action.getId();
controlID = self.getConrolID(action);
if actionID in EXIT_CLICK and controlID == BACK_BTN:
self.close();
pass;
Posts: 180
Joined: Aug 2016
(2016-12-23, 17:53)Taifxx Wrote: (2016-12-23, 17:22)Protocol-X Wrote: This is what i ended up doing in my final code.
Don't forget send uncaught events to default method (xbmcgui.WindowXMLDialog.onAction(self, action) or other depending on how you define class) else you will can not close dialog/window by ESC button on keyboard or BACK on remote etc.
Could you explain? The docs say these are handled by default but I have always had issues without capturing them myself. Or could you show a small example?
Posts: 180
Joined: Aug 2016
Ah that was simple. I appreciate the info. This will allow me to remove some additional coding.