From b0aef1bb2b0d70d48db80ad13a7863d35c137a71 Mon Sep 17 00:00:00 2001 From: Juan Campa Date: Sat, 29 Jan 2022 15:23:37 -0500 Subject: [PATCH 1/2] Add on_hover_text_at_pointer --- egui/src/response.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/egui/src/response.rs b/egui/src/response.rs index 2d20d1728bb..952ee19018f 100644 --- a/egui/src/response.rs +++ b/egui/src/response.rs @@ -383,6 +383,14 @@ impl Response { true } + /// Like `on_hover_text`, but show the text next to cursor. + #[doc(alias = "tooltip")] + pub fn on_hover_text_at_pointer(self, text: impl Into) -> Self { + self.on_hover_ui_at_pointer(|ui| { + ui.add(crate::widgets::Label::new(text)); + }) + } + /// Show this text if the widget was hovered (i.e. a tooltip). /// /// The text will not be visible if the widget is not enabled. From aa3c13d541f6f000f4f53f2deac874d4b83716bc Mon Sep 17 00:00:00 2001 From: Juan Campa Date: Sat, 29 Jan 2022 15:50:08 -0500 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3351f20dae2..efd0287eca3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w * `Context::load_texture` to convert an image into a texture which can be displayed using e.g. `ui.image(texture, size)` ([#1110](https://github.com/emilk/egui/pull/1110)). * Added `Ui::add_visible` and `Ui::add_visible_ui`. * Added `CollapsingHeader::icon` to override the default open/close icon using a custom function. ([1147](https://github.com/emilk/egui/pull/1147)) +* Added `Response::on_hover_text_at_pointer` as a convenience akin to `Response::on_hover_text`. ([1179](https://github.com/emilk/egui/pull/1179)) ### Changed 🔧 * ⚠️ `Context::input` and `Ui::input` now locks a mutex. This can lead to a dead-lock is used in an `if let` binding!