Skip to content

Commit

Permalink
plot interact demo now prints a human readable item name
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Jan 30, 2024
1 parent 08af004 commit b6f19d0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/egui_demo_lib/src/demo/plot_demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ impl InteractionDemo {
..,
100,
))
.color(Color32::RED)
.id(egui::Id::new("sin")),
);
plot_ui.line(
Expand All @@ -808,6 +809,7 @@ impl InteractionDemo {
..,
100,
))
.color(Color32::BLUE)
.id(egui::Id::new("cos")),
);

Expand Down Expand Up @@ -841,7 +843,15 @@ impl InteractionDemo {
pointer_coordinate_drag_delta.x, pointer_coordinate_drag_delta.y
);
ui.label(format!("pointer coordinate drag delta: {coordinate_text}"));
ui.label(format!("hovered plot item: {hovered_plot_item:?}"));

let hovered_item = if hovered_plot_item == Some(egui::Id::new("sin")) {
"red sin"
} else if hovered_plot_item == Some(egui::Id::new("cos")) {
"blue cos"
} else {
"none"
};
ui.label(format!("hovered plot item: {hovered_item}"));

response
}
Expand Down

0 comments on commit b6f19d0

Please sign in to comment.