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

Detect mouse events in a Plot #759

Closed
IndianBoy42 opened this issue Oct 2, 2021 · 4 comments
Closed

Detect mouse events in a Plot #759

IndianBoy42 opened this issue Oct 2, 2021 · 4 comments
Labels
egui_plot Related to egui_plot feature New feature or request

Comments

@IndianBoy42
Copy link

I want to make an interactive plot, so this involves being able to click and drag the various plot elements. Currently you can use the general Response::clicked_by etc for detecting clicks/drags anywhere on the whole plot but it has a few drawbacks:

  • The positions/deltas we get are in pixels, not plot coordinates.
  • We would have to somehow manually check which plot elements were interacted with.

I think it would be nice if adding elements to the plot also gave something like a Response object that allows us to check interactions.
Making things automatically be draggable (especially Points, Polygons) would be nice as well.
As a long term goal, perhaps we could have projection/closest point methods as well. But first the ability to detect click/drag on Plot elements would be good

I am just starting to learn how to use egui, so apologies if I have missed an existing feature.

@IndianBoy42
Copy link
Author

Related to #734 but more about events

@emilk emilk added feature New feature or request egui_plot Related to egui_plot labels Oct 2, 2021
@EmbersArc
Copy link
Contributor

Mouse position and delta are now available in #766, feel free to give it a try.

@jbuckmccready
Copy link

@EmbersArc The mouse position functions work great! Related to this interactive/event handling plots I would like to enable/disable plot dragging to change the bounds based on where in the plot the pointer was pressed (example use case: if certain parts of the plot are editable and a control point is pressed I want to disable dragging to change bounds and instead use the drag to change the plot data). The problem is the Plot is consumed in the call to show so I am not sure how to disable dragging based on the pressed plot location. I thought maybe I could just implement dragging plot bounds separately but I couldn't find a way to edit the plot bounds programmatically.

@emilk
Copy link
Owner

emilk commented Apr 16, 2022

I think this is closed by the PR:s above

@emilk emilk closed this as completed Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
egui_plot Related to egui_plot feature New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants