Custom control doesn't catch all wx.EVT_LEFT_DOWN events when mouse is clicked in quick succession.

I’ve created a custom control based on GenStaticBitmap/StaticBitmap which behaves like a checkbox for a touch screen application. Like a checkbox, the object redraws as selected/unselected on the EVT_LEFT_UP event. It’s important that I record the time the object is selected on a EVT_LEFT_DOWN event to eliminate the added delay of the whole mouse click cycle.

Python 2.7.2 and wxPython 2.8.12.1 are installed.

I’ve attached all 3 files required to run the test showing the EVT_LEFT_UP is caught consistently, while some of the EVT_LEFT_DOWN are missed.

SelectableStaticBitmap.py (5.27 KB)

test_SelectableStaticBitmap.py (2.85 KB)

test_images.py (93.9 KB)

If they are fast enough then they are detected as double-click events.

···

On 3/26/12 6:44 AM, Robert Mavrinac wrote:

I've created a custom control based on GenStaticBitmap/StaticBitmap
which behaves like a checkbox for a touch screen application. Like a
checkbox, the object redraws as selected/unselected on the EVT_LEFT_UP
event. It's important that I record the time the object is selected on a
EVT_LEFT_DOWN event to eliminate the added delay of the whole mouse
click cycle.

Python 2.7.2 and wxPython 2.8.12.1 are installed.

I've attached all 3 files required to run the test showing the
EVT_LEFT_UP is caught consistently, while some of the EVT_LEFT_DOWN are
missed.

--
Robin Dunn
Software Craftsman

Of course they are … Thanks.
I’ll try to find all the mouse events generated and and post the fix.

···

On Monday, March 26, 2012 1:22:51 PM UTC-4, Robin Dunn wrote:

On 3/26/12 6:44 AM, Robert Mavrinac wrote:

I’ve created a custom control based on GenStaticBitmap/StaticBitmap
which behaves like a checkbox for a touch screen application. Like a
checkbox, the object redraws as selected/unselected on the EVT_LEFT_UP
event. It’s important that I record the time the object is selected on a
EVT_LEFT_DOWN event to eliminate the added delay of the whole mouse
click cycle.

Python 2.7.2 and wxPython 2.8.12.1 are installed.

I’ve attached all 3 files required to run the test showing the
EVT_LEFT_UP is caught consistently, while some of the EVT_LEFT_DOWN are
missed.
If they are fast enough then they are detected as double-click events.


Robin Dunn
Software Craftsman
http://wxPython.org

This now works the way I expected it to:

    ...
    self.Bind(wx.EVT_MOUSE_EVENTS, self.OnLeftDown)
    self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
    ...

def OnLeftDown(self, event):
    eventType = event.GetEventType()
    if eventType in [wx.wxEVT_LEFT_DOWN, wx.wxEVT_LEFT_DCLICK]:
        pass
    event.Skip()

def OnLeftUp(self, event):
    if not self.IsEnabled() :
        return
    self.SendCheckBoxEvent()
    event.Skip()