import matplotlib.pyplot as plt
def onclick(event):
print(event.button)
fig = plt.figure()
connection_id = fig.canvas.mpl_connect('button_press_event', onclick)
plt.show()
With this code, the problem is double-clicks are hitting onclick()
handler three times. I guess that it is receiving both the clicks, as well as an additional double-click event.
How can I change this behavior so that the event handler is not fired for double-click events? Alternatively, how can I detect a double-click from the event instance so that I can ignore that case?
Note: button_release_event
does not have this problem, but I want to fire on the button_press_event
When i had matplotlib version 1.1rc, i was not able to catch dblclick event. Later, I wrote code for matplotlib 1.2 and that is ok
import matplotlib.pyplot as plt
fig = plt.figure()
def onclick(event):
if event.dblclick:
print event.button
connection_id = fig.canvas.mpl_connect('button_press_event', onclick)
plt.show()