Distinguish Between Single And Double Click With Matplotlib
I'm trying to catch single clicks and double clicks on my figure. As stated in another answer, the event contains event.dblclick which is False or True, at least in Version 1.4.2,
Solution 1:
You need a software debouncer.
Basically, you start a timer on the 1st click. If the timer runs out, then you proceed to process the single-click event. If a 2nd click is detected within the timer, process a double-click event.
This can actually be expanded to n-clicks if needed. I've found some uses for triple-click events.
Here is one implemented in wxPython. Should be relatively easy to port to matplotlib.
Also, if you're on Windows, I would recommend using the user's double-click speed for your timer (Control Panel: Mouse). You can access it with:
get_double_click_time():
""" Gets the Windows double click time in ms """from ctypes import windll
returnint(windll.user32.GetDoubleClickTime())
I haven't yet figured out how to grab the dclick time from Mac or Linux (but I also don't have a need to).
Post a Comment for "Distinguish Between Single And Double Click With Matplotlib"