Capture every mouse down press Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
User avatar
Artifact2238
Earned a small fee
Earned a small fee
Posts: 23
Joined: Mon May 28, 2018 2:43 am

Capture every mouse down press

Post by Artifact2238 »

So I was a bit confused here for a while because despite me rapidly pressing the mouse buttons, it seemed like only every other time I clicked that a LeftDown event (wxEVT_LEFT_DOWN) would be produced, unless I was also moving the mouse as I clicked.

I thought this was really weird, until I figured out that it was producing double-click events instead of left-down events.

Three questions, if you don't mind:

1. Are double-click events only produced if the mouse had not moved since last time?
2. Can the pressing down of the mouse ever produce both an event.LeftDown() and event.LeftDClick() immediately after each other? Or is it only one or the other?
3. Since just specifying if (event.LeftDown()) { } apparently isn't enough to capture every mouse click,
can it be assured that doing if (event.LeftDown() || event.LeftDClick()) { } will be? So far it seems to work.

i.e.

Code: Select all

void MyCanvas::OnMouse(wxMouseEvent& event)
{
    if (event.LeftDown())
    {
        // would only happen every other click unless I was also moving
    }
    
    //
    
    if (event.LeftDown() || event.LeftDClick())
    {
        //user definitely positively pressed the button mouse button down here?
    }
}
Thanks for reading.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Capture every mouse down press

Post by doublemax »

1. Are double-click events only produced if the mouse had not moved since last time?
That's OS specific, but usually yes. Usually there is a tolerance of a few pixels the mouse can move and it still reports a double click.
2. Can the pressing down of the mouse ever produce both an event.LeftDown() and event.LeftDClick() immediately after each other? Or is it only one or the other?
There will always be a single click event before every double click event. Otherwise the OS had to wait for a certain amount of time after a click in order to know if it's a single or double click.

Therefore - from a GUI point of view - every double click action should be a logical extension of a single click action, e.g. single click = select, double click = action
3. Since just specifying if (event.LeftDown()) { } apparently isn't enough to capture every mouse click,
can it be assured that doing if (event.LeftDown() || event.LeftDClick()) { } will be? So far it seems to work.
Yes.
Use the source, Luke!
User avatar
Artifact2238
Earned a small fee
Earned a small fee
Posts: 23
Joined: Mon May 28, 2018 2:43 am

Re: Capture every mouse down press

Post by Artifact2238 »

(1.)
Thanks. So I guess for potential touchscreen/stylus-based programs, the programmer has to put in some extra logic themselves (depending on OS) if they want more things to count as double clicks (because it's impossible to keep your hand perfectly in the same spot between stylus presses).

Thank you for the confirmation on the other points, as well.
Post Reply