Skip to content

Conversation

@Mikalai
Copy link
Contributor

@Mikalai Mikalai commented May 16, 2024

Description

Windows has dedicated message for double click. Old behavior with this handler

class IntersectionHandler : public vsg::Inherit<vsg::Visitor, IntersectionHandler>
{
public:

    void apply(vsg::ButtonReleaseEvent& evt) override {
        std::cout << "Release button = " << evt.button << " mask = " << evt.mask << std::endl;
    }

    void apply(vsg::ButtonPressEvent& evt) override
    {
        std::cout << "Press button = " << evt.button << " mask = " << evt.mask << std::endl;
    }

};

is

Press button = 1 mask = 256
Release button = 1 mask = 0
Press button = 0 mask = 256
Release button = 1 mask = 0

Where button 0 doesn't look correct value for left button double click. With this changes:

Press button = 1 mask = 256
Release button = 1 mask = 0
Press button = 1 mask = 256
Release button = 1 mask = 0

And this depicts correctly the action.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

It was tested with handler above.

Test Configuration:
Windows 11

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings

@robertosfield
Copy link
Collaborator

I'm not familiar with Win32 event handling (Win32_Window.cpp by @tomhog) so I need learn the background a bit before I can properly review/test Win32 submissions.

When Windows generates the WM_LBUTTONDBLCLK etc. event does it it entirely replace the WM_LBUTTONDOWN event? Or does it come in as well? Of as well does it come in before or after.

Also when WM_LBUTTONDBLCLK etc. event domes in does it get matched the WM_LBUTTONUP or similar event once the button is finally released?

This topic also touches upon whether it's time for use to add a vsg::DoubleClickEvent alongside the existing vsg::ButtonDownEvent/ButtonReleaseEvent.

While Win32 should be straight forward to map to this type of event, other UI libraries like Xcb don't have a double click event type so to we'd need to simulate the behavior and generate the DoubleClickEvent in Xcb_Window.cpp etc to ensure user applications can check for double click events in a coherent way across platforms.

Thoughts?

@Mikalai
Copy link
Contributor Author

Mikalai commented May 17, 2024

Regarding the behavior on windows:

Only windows that have the CS_DBLCLKS style can receive WM_LBUTTONDBLCLK messages, which the system generates whenever the user presses, releases, and again presses the left mouse button within the system's double-click time limit. Double-clicking the left mouse button actually generates a sequence of four messages: WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK, and WM_LBUTTONUP.
https://learn.microsoft.com/en-us/windows/win32/inputdev/wm-lbuttondblclk

Having a dedicated vsg::DoubleClickEvent is a good idea.

@robertosfield robertosfield merged commit 1f303f9 into vsg-dev:master May 17, 2024
@robertosfield
Copy link
Collaborator

To help with testing features like this I have extended the vsginput example to have a --print command line option that enables the writing of the event strings out to the console, making it easier to step through what events the VSG has generated.

vsg-dev/vsgExamples@266faac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants