Skip to content

Commit

Permalink
Merge pull request #1944 from mdboom/cancel-zoom
Browse files Browse the repository at this point in the history
ValueError exception in drag_zoom (tk backend)
  • Loading branch information
mdboom committed Jun 11, 2013
2 parents b0259b3 + fcfd408 commit ddf2c57
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2863,6 +2863,18 @@ def press_pan(self, event):

def press_zoom(self, event):
"""the press mouse button in zoom to rect mode callback"""
# If we're already in the middle of a zoom, pressing another
# button works to "cancel"
if self._ids_zoom != []:
for zoom_id in self._ids_zoom:
self.canvas.mpl_disconnect(zoom_id)
self.release(event)
self.draw()
self._xypress = None
self._button_pressed = None
self._ids_zoom = []
return

if event.button == 1:
self._button_pressed = 1
elif event.button == 3:
Expand Down

0 comments on commit ddf2c57

Please sign in to comment.