Skip to content

Commit dd03d4a

Browse files
committed
Add release event for lasso_demo
1 parent 78442c4 commit dd03d4a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

examples/event_handling/lasso_demo.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ def __init__(self, ax, data):
5757

5858
ax.add_collection(self.collection)
5959

60-
self.cid = self.canvas.mpl_connect('button_press_event', self.on_press)
60+
self.cid_press = self.canvas.mpl_connect('button_press_event',
61+
self.on_press)
62+
self.cid_release = self.canvas.mpl_connect('button_release_event',
63+
self.on_release)
6164

6265
def callback(self, verts):
6366
facecolors = self.collection.get_facecolors()
@@ -70,7 +73,6 @@ def callback(self, verts):
7073
facecolors[i] = Datum.colorout
7174

7275
self.canvas.draw_idle()
73-
self.canvas.widgetlock.release(self.lasso)
7476
del self.lasso
7577

7678
def on_press(self, event):
@@ -84,6 +86,11 @@ def on_press(self, event):
8486
# acquire a lock on the widget drawing
8587
self.canvas.widgetlock(self.lasso)
8688

89+
def on_release(self, event):
90+
if self.canvas.widgetlock.locked():
91+
self.canvas.widgetlock.release(self.lasso)
92+
return
93+
8794

8895
if __name__ == '__main__':
8996

0 commit comments

Comments
 (0)