Trigger a button event when its pressed versus released?

I’m working on a project where I’d like to fire a button event when a bitmap button is pressed, versus when its released. Using this method it doesn’t fire until I release the mouse:

self.Bind(wx.EVT_BUTTON, self.pressed(), id=self.whatever)

Can anyone think of a way to fire the event the moment its pressed?

I know that means detecting double clicks and things like that is impossible, which is fine.

How about using wx.EVT_LEFT_DOWN and wx.EVT_LEFT_UP [1] which trigger on left mouse down and up?

-Haris

[1] wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

···

On Apr 7, 2014, at 10:22 PM, wrybread <wrybread@gmail.com> wrote:

I'm working on a project where I'd like to fire a button event when a bitmap button is pressed, versus when its released. Using this method it doesn't fire until I release the mouse:

self.Bind(wx.EVT_BUTTON, self.pressed(), id=self.whatever)

Can anyone think of a way to fire the event the moment its pressed?

I know that means detecting double clicks and things like that is impossible, which is fine.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I'm working on a project where I'd like to fire a button event when a
bitmap button is pressed, versus when its released. Using this method it
doesn't fire until I release the mouse:

self.Bind(wx.EVT_BUTTON, self.pressed(), id=self.whatever)

Can anyone think of a way to fire the event the moment its pressed?

As Haris said, wx.EVT_LEFT_DOWN.

I know that means detecting double clicks and things like that is
impossible, which is fine.

Widgets can't detect double clicks? Then how could double clicks ever be
used in software? Yet they are. So of course they can be detected (unless
I misunderstand what you meant?). And so wxPython has (from the same page
he linked):

EVT_LEFT_DCLICK Left mouse button double click event

···

On Tue, Apr 8, 2014 at 1:22 AM, wrybread <wrybread@gmail.com> wrote:

C M wrote:

As Haris said, wx.EVT_LEFT_DOWN.

    I know that means detecting double clicks and things like that is
    impossible, which is fine.

Widgets can't detect double clicks? Then how could double clicks ever
be used in software? Yet they are. So of course they can be detected
(unless I misunderstand what you meant?). And so wxPython has (from the
same page he linked):

EVT_LEFT_DCLICK Left mouse button double click event

It may depend on the platform, but I've seen cases where if the LEFT_DOWN handler eats the event then the system doesn't see it and won't know that a dclick event should be sent if there is another left-down within the time out period. Calling Skip should allow it to keep working if you need it.

···

--
Robin Dunn
Software Craftsman