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

Feature: Prevent dragging window while holding click on widget and moving mouse #5625

Open
joshua-holmes opened this issue Jan 21, 2025 · 0 comments

Comments

@joshua-holmes
Copy link
Contributor

First, I love what I see with egui! Thanks for making the tool!

Problem

Bit of a nitpick, but I was a little bothered by the fact that when I click on a widget and drag the mouse, the window moved. This happened when I accidentally moved the mouse slightly while attempting to click on a button. I don't usually see that in applications. I would expect the window to stay put and the button to still be clicked, so long as my mouse was still over the button upon release.

Experience:
Image

Solution

I see that the sense used for Button is Sense::click() here. I also see that Label uses Sense::click() when touchscreen is enabled and Sense::click_and_drag() when touchscreen is disabled here. When I apply the same logic to the button, I get a result much closer to expected.

Desired:
Image

I think this effect should be applied to the following widgets:

  • Button
  • Checkbox
  • RadioButton
  • SelectableLabel
  • ComboBox
  • ColorPicker

Considerations

Using Sense::click_and_drag() seems like the wrong approach to solve the problem (even though it works) because the widgets in the list above are not really "draggable". Possibly creating another Sense bitflag is the solution, but before discussing implementation details, I wanted some thoughts on the feature in general. Thanks!

@joshua-holmes joshua-holmes changed the title Prevent dragging window while holding click on widget and moving mouse Feature: Prevent dragging window while holding click on widget and moving mouse Jan 21, 2025
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

1 participant