diff --git a/crates/egui_demo_lib/src/demo/widget_gallery.rs b/crates/egui_demo_lib/src/demo/widget_gallery.rs index 82589c402..4189e61c9 100644 --- a/crates/egui_demo_lib/src/demo/widget_gallery.rs +++ b/crates/egui_demo_lib/src/demo/widget_gallery.rs @@ -109,7 +109,7 @@ impl WidgetGallery { date, } = self; - ui.add(doc_link_label("Label", "label,heading")); + ui.add(doc_link_label("Label", "label")); ui.label("Welcome to the widget gallery!"); ui.end_row(); @@ -121,7 +121,7 @@ impl WidgetGallery { ); ui.end_row(); - ui.add(doc_link_label("TextEdit", "TextEdit,text_edit")); + ui.add(doc_link_label("TextEdit", "TextEdit")); ui.add(egui::TextEdit::singleline(string).hint_text("Write something here")); ui.end_row(); @@ -149,10 +149,7 @@ impl WidgetGallery { }); ui.end_row(); - ui.add(doc_link_label( - "SelectableLabel", - "selectable_value,SelectableLabel", - )); + ui.add(doc_link_label("SelectableLabel", "SelectableLabel")); ui.horizontal(|ui| { ui.selectable_value(radio, Enum::First, "First"); ui.selectable_value(radio, Enum::Second, "Second"); @@ -216,7 +213,11 @@ impl WidgetGallery { #[cfg(feature = "chrono")] { let date = date.get_or_insert_with(|| chrono::offset::Utc::now().date_naive()); - ui.add(doc_link_label("DatePickerButton", "DatePickerButton")); + ui.add(doc_link_label_with_crate( + "egui_extras", + "DatePickerButton", + "DatePickerButton", + )); ui.add(egui_extras::DatePickerButton::new(date)); ui.end_row(); } @@ -237,7 +238,7 @@ impl WidgetGallery { }); ui.end_row(); - ui.add(doc_link_label("Plot", "plot")); + ui.add(doc_link_label_with_crate("egui_plot", "Plot", "plot")); example_plot(ui); ui.end_row(); @@ -273,8 +274,16 @@ fn example_plot(ui: &mut egui::Ui) -> egui::Response { } fn doc_link_label<'a>(title: &'a str, search_term: &'a str) -> impl egui::Widget + 'a { + doc_link_label_with_crate("egui", title, search_term) +} + +fn doc_link_label_with_crate<'a>( + crate_name: &'a str, + title: &'a str, + search_term: &'a str, +) -> impl egui::Widget + 'a { let label = format!("{title}:"); - let url = format!("https://docs.rs/egui?search={search_term}"); + let url = format!("https://docs.rs/{crate_name}?search={search_term}"); move |ui: &mut egui::Ui| { ui.hyperlink_to(label, url).on_hover_ui(|ui| { ui.horizontal_wrapped(|ui| {