Skip to content
Permalink
Browse files

Merge pull request #1344 from JillHolliday/buttons_patch

Update buttons.py
  • Loading branch information...
RobinD42 committed Sep 6, 2019
2 parents 3bce916 + 883d093 commit 7f8a697f7f10ca190d96d7f46e49f10b9d31a7d1
Showing with 28 additions and 12 deletions.
  1. +28 −12 wx/lib/buttons.py
@@ -174,17 +174,18 @@ def __init__(self, parent, id=-1, label='',
self.SetInitialSize(size)
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))

self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDown)
self.Bind(wx.EVT_MOTION, self.OnMotion)
self.Bind(wx.EVT_SET_FOCUS, self.OnGainFocus)
self.Bind(wx.EVT_KILL_FOCUS, self.OnLoseFocus)
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_ERASE_BACKGROUND, lambda evt: None)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDown)
self.Bind(wx.EVT_MOTION, self.OnMotion)
self.Bind(wx.EVT_SET_FOCUS, self.OnGainFocus)
self.Bind(wx.EVT_KILL_FOCUS, self.OnLoseFocus)
self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self.OnLoseCapture)
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_ERASE_BACKGROUND, lambda evt: None)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.InitOtherEvents()


@@ -543,7 +544,7 @@ def OnLeftDown(self, event):
:param `event`: a :class:`wx.MouseEvent` event to be processed.
"""

if not self.IsEnabled():
if (not self.IsEnabled()) or self.HasCapture():
return

self.up = False
@@ -624,6 +625,18 @@ def OnLoseFocus(self, event):
self.Update()


def OnLoseCapture(self, event):
"""
Handles the ``wx.EVT_MOUSE_CAPTURE_LOST`` event for :class:`GenButton`.
:param `event`: a :class:`wx.MouseCaptureLostEvent` event to be processed.
"""

self.up = True
self.Refresh()
self.Update()


def OnKeyDown(self, event):
"""
Handles the ``wx.EVT_KEY_DOWN`` event for :class:`GenButton`.
@@ -962,6 +975,9 @@ def OnLeftDown(self, event):
return

self.saveUp = self.up
if self.HasCapture():
return

self.up = not self.up
self.CaptureMouse()
self.SetFocus()

0 comments on commit 7f8a697

Please sign in to comment.
You can’t perform that action at this time.