Skip to content

Commit

Permalink
Added ability to drag out of axes with span selector. event was not r…
Browse files Browse the repository at this point in the history
…egistered before.

svn path=/trunk/matplotlib/; revision=1874
  • Loading branch information
cmoad committed Nov 18, 2005
1 parent 866a376 commit 4a595e0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,10 @@ def __init__(self, ax, onselect, direction, minspan=None, useblit=False, rectpro
self.useblit = useblit
self.minspan = minspan

# Needed when dragging out of axes
self.buttonDown = False
self.prev = (0, 0)

if self.direction == 'horizontal':
trans = blend_xy_sep_transform(self.ax.transData, self.ax.transAxes)
w,h = 0,1
Expand Down Expand Up @@ -760,6 +764,7 @@ def ignore(self, event):
def press(self, event):
'on button press event'
if self.ignore(event): return
self.buttonDown = True

self.rect.set_visible(self.visible)
if self.direction == 'horizontal':
Expand All @@ -771,15 +776,17 @@ def press(self, event):

def release(self, event):
'on button release event'
if self.pressv is None or self.ignore(event): return
if self.pressv is None or (self.ignore(event) and not self.buttonDown): return
self.buttonDown = False

self.rect.set_visible(False)
self.canvas.draw()
vmin = self.pressv
if self.direction == 'horizontal':
vmax = event.xdata
vmax = event.xdata or self.prev[0]
else:
vmax = event.ydata
vmax = event.ydata or self.prev[1]

if vmin>vmax: vmin, vmax = vmax, vmin
span = vmax - vmin
if self.minspan is not None and span<self.minspan: return
Expand All @@ -802,7 +809,8 @@ def update(self):
def onmove(self, event):
'on motion notify event'
if self.pressv is None or self.ignore(event): return
x,y = event.xdata, event.ydata
x, y = event.xdata, event.ydata
self.prev = x, y
if self.direction == 'horizontal':
v = x
else:
Expand Down

0 comments on commit 4a595e0

Please sign in to comment.