Skip to content

Better distinction of dragged vs clicked #547

@WeiPhil

Description

@WeiPhil

Hello,
First of all, I'd like to point out how amazing the library is. It does most of what one would expect from an immediate-mode GUI and can easily handle new cases/features. Thanks for all the time passed on working on this!
Now on my issue, which might actually not be an issue but intended. When using dragged() on a Response of a widget to detect a change, I noticed that clicking on a widget also seems to count as dragged. At least on an egui::DragValue. Is this intended? In my case, I want to allow the user to change the field (by clicking and entering a custom value) without triggering a change, if not explicitly dragged. A workaround that works well for me uses an epsilon value to differentiate between a simple click or a "real" drag action, something like: if response.drag_delta().max_elem() > 1e-5 { do_something(); }. Also note that (response.dragged() && !response.clicked()) does not result in not detecting a change when clicked (which definitely looks like a bug).
Should this approach be the default behaviour when checking for dragged(), or are there specific use cases where a simple click should count as a drag event? My choice of epsilon is, of course, completely arbitrary, and I suppose there are better choices.
Best,
Philippe

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions