Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click and drag tiggers buttons and checkboxes repeatedly #773

Closed
clement-roblot opened this issue Oct 23, 2023 · 1 comment
Closed

Click and drag tiggers buttons and checkboxes repeatedly #773

clement-roblot opened this issue Oct 23, 2023 · 1 comment

Comments

@clement-roblot
Copy link
Contributor

Hi there,

I made a video but for some reason it doesn´t look like the real deal. But here it is anyway:

2023-10-23 21-19-00

If you click on a checkbox or a button and keep your left mouse button pressed and start drawing the mouse sideways, it will toggle on and off the checkbox (or repeatedly click the button). This behavior leads to sometimes having a button triggering the onClick event twice even though I though I clicked it only once.

I would like to add an option to the button object (and also to the checkbox object) that would enable a mechanism looking for a released to press motion to trigger an OnClick event, rather than just looking for press events as it is now. Here is a quick example that works for me for a button:

image

Does such an implementation look valid, should I go forth with a PR?

@ArthurSonzogni
Copy link
Owner

It might. Would you like to propose a pull request?

ArthurSonzogni added a commit that referenced this issue Dec 26, 2024
This fixes: #773

Dragging the mouse with the left button pressed now avoids activating multiple
checkboxes.

Add support for detecting mouse press transition. Added:
```cpp
// The previous mouse event.
Mouse Mouse::previous;

// Return whether the mouse transitionned from:
// released to pressed => IsPressed()
// pressed to pressed => IsHeld()
// pressed to released => IsReleased()
bool Mouse::IsPressed(Button button) const;
bool Mouse::IsHeld(Button button) const;
bool Mouse::IsReleased(Button button) const;
```
A couple of components are now activated when the mouse is pressed,
as opposed to released.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
ArthurSonzogni added a commit that referenced this issue Dec 26, 2024
This fixes: #773

Dragging the mouse with the left button pressed now avoids activating multiple
checkboxes.

Add support for detecting mouse press transition. Added:
```cpp
// The previous mouse event.
Mouse Mouse::previous;

// Return whether the mouse transitionned from:
// released to pressed => IsPressed()
// pressed to pressed => IsHeld()
// pressed to released => IsReleased()
bool Mouse::IsPressed(Button button) const;
bool Mouse::IsHeld(Button button) const;
bool Mouse::IsReleased(Button button) const;
```
A couple of components are now activated when the mouse is pressed,
as opposed to released.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
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

No branches or pull requests

2 participants