Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d0eb9fe

Browse files
committed
applied sf patch 2815064 (middle button events for wx) and patch 2818092 (resize events for wx)
svn path=/branches/v0_99_maint/; revision=7343
1 parent a400c35 commit d0eb9fe

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,11 @@ def do_nothing(*args, **kwargs):
772772
bind(self, wx.EVT_LEAVE_WINDOW, self._onLeave)
773773
bind(self, wx.EVT_ENTER_WINDOW, self._onEnter)
774774
bind(self, wx.EVT_IDLE, self._onIdle)
775+
#Add middle button events
776+
bind(self, wx.EVT_MIDDLE_DOWN, self._onMiddleButtonDown)
777+
bind(self, wx.EVT_MIDDLE_DCLICK, self._onMiddleButtonDown)
778+
bind(self, wx.EVT_MIDDLE_UP, self._onMiddleButtonUp)
779+
775780
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
776781

777782
self.macros = {} # dict from wx id to seq of macros
@@ -1183,6 +1188,7 @@ def _onSize(self, evt):
11831188
# so no need to do anything here except to make sure
11841189
# the whole background is repainted.
11851190
self.Refresh(eraseBackground=False)
1191+
FigureCanvasBase.resize_event(self)
11861192

11871193
def _get_key(self, evt):
11881194

@@ -1251,6 +1257,24 @@ def _onLeftButtonUp(self, evt):
12511257
if self.HasCapture(): self.ReleaseMouse()
12521258
FigureCanvasBase.button_release_event(self, x, y, 1, guiEvent=evt)
12531259

1260+
#Add middle button events
1261+
def _onMiddleButtonDown(self, evt):
1262+
"""Start measuring on an axis."""
1263+
x = evt.GetX()
1264+
y = self.figure.bbox.height - evt.GetY()
1265+
evt.Skip()
1266+
self.CaptureMouse()
1267+
FigureCanvasBase.button_press_event(self, x, y, 2, guiEvent=evt)
1268+
1269+
def _onMiddleButtonUp(self, evt):
1270+
"""End measuring on an axis."""
1271+
x = evt.GetX()
1272+
y = self.figure.bbox.height - evt.GetY()
1273+
#print 'release button', 1
1274+
evt.Skip()
1275+
if self.HasCapture(): self.ReleaseMouse()
1276+
FigureCanvasBase.button_release_event(self, x, y, 2, guiEvent=evt)
1277+
12541278
def _onMouseWheel(self, evt):
12551279
"""Translate mouse wheel events into matplotlib events"""
12561280

0 commit comments

Comments
 (0)