From 953a652c29df0b7d894bf629cf75f06d2a169219 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 30 Jan 2021 15:45:57 +0100 Subject: [PATCH] Add Hyperlink::from_label_and_url --- egui/src/widgets/hyperlink.rs | 45 ++++++++++++++++------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/egui/src/widgets/hyperlink.rs b/egui/src/widgets/hyperlink.rs index 88f517d2..20807ef6 100644 --- a/egui/src/widgets/hyperlink.rs +++ b/egui/src/widgets/hyperlink.rs @@ -3,31 +3,35 @@ use crate::*; /// A clickable hyperlink, e.g. to `"https://github.com/emilk/egui"`. #[must_use = "You should put this widget in an ui with `ui.add(widget);`"] pub struct Hyperlink { - // TODO: wrap Label url: String, - text: String, - pub(crate) text_style: Option, + label: Label, } impl Hyperlink { pub fn new(url: impl Into) -> Self { let url = url.into(); Self { - text: url.clone(), - url, - text_style: None, + url: url.clone(), + label: Label::new(url), + } + } + + pub fn from_label_and_url(label: impl Into