From 66cbb61ad5a4434d6c723ff81f416205d39c6299 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 10 Aug 2023 13:14:19 +0200 Subject: [PATCH] Add `PlotUi::response()` to replace `plot_clicked()` etc (#3223) Closes https://github.com/emilk/egui/pull/2571 --- crates/egui/src/widgets/plot/mod.rs | 8 ++++++++ crates/egui_demo_lib/src/demo/plot_demo.rs | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/plot/mod.rs b/crates/egui/src/widgets/plot/mod.rs index 8f04be4f..9fa09b7e 100644 --- a/crates/egui/src/widgets/plot/mod.rs +++ b/crates/egui/src/widgets/plot/mod.rs @@ -1081,17 +1081,25 @@ impl PlotUi { .push(BoundsModification::Translate(delta_pos)); } + /// Can be used to check if the plot was hovered or clicked. + pub fn response(&self) -> &Response { + &self.response + } + /// Returns `true` if the plot area is currently hovered. + #[deprecated = "Use plot_ui.response().hovered()"] pub fn plot_hovered(&self) -> bool { self.response.hovered() } /// Returns `true` if the plot was clicked by the primary button. + #[deprecated = "Use plot_ui.response().clicked()"] pub fn plot_clicked(&self) -> bool { self.response.clicked() } /// Returns `true` if the plot was clicked by the secondary button. + #[deprecated = "Use plot_ui.response().secondary_clicked()"] pub fn plot_secondary_clicked(&self) -> bool { self.response.secondary_clicked() } diff --git a/crates/egui_demo_lib/src/demo/plot_demo.rs b/crates/egui_demo_lib/src/demo/plot_demo.rs index 8c5bcfd3..2f6180ea 100644 --- a/crates/egui_demo_lib/src/demo/plot_demo.rs +++ b/crates/egui_demo_lib/src/demo/plot_demo.rs @@ -761,7 +761,7 @@ impl InteractionDemo { plot_ui.pointer_coordinate(), plot_ui.pointer_coordinate_drag_delta(), plot_ui.plot_bounds(), - plot_ui.plot_hovered(), + plot_ui.response().hovered(), ) });