pub struct Hyperlink { /* private fields */ }Expand description
A link as a widget of its own: accent colored text that underlines on hover, is reachable with Tab, and activates on release over it (or Enter and Space). A link that is longer than the line wraps, and every line fragment is clickable.
Showing a link only reports the click: Response::link_activation tells how it was
activated, and the application decides what happens. Opening the address in the system
browser is opt-in with Hyperlink::open_in_browser, and checks the scheme first.
if ui.hyperlink_to("Documentation", "https://example.com/docs").clicked() {
// navigate, or open it yourself
}Implementations§
Source§impl Hyperlink
impl Hyperlink
pub fn new(text: impl Into<String>) -> Self
pub fn url(self, url: impl Into<String>) -> Self
Sourcepub fn visited(self, visited: bool) -> Self
pub fn visited(self, visited: bool) -> Self
The application knows the link was followed; it gets the visited color.
pub fn enabled(self, enabled: bool) -> Self
Sourcepub fn tooltip(self, text: impl Into<String>) -> Self
pub fn tooltip(self, text: impl Into<String>) -> Self
Shown on hover. Without one the full address is shown, when there is one.
pub fn underline(self, underline: Underline) -> Self
pub fn id_source(self, source: impl Hash) -> Self
pub fn style(self, style: HyperlinkStyle) -> Self
Sourcepub fn open_in_browser(self) -> Self
pub fn open_in_browser(self) -> Self
Open the address with the system handler when the link is activated, after checking
its scheme against the default allowlist (https, http, mailto). Without this the
library never opens anything.
Sourcepub fn open_with(self, policy: UrlPolicy) -> Self
pub fn open_with(self, policy: UrlPolicy) -> Self
Like Self::open_in_browser with an explicit allowlist.
Sourcepub fn selectable(self, selectable: bool) -> Self
pub fn selectable(self, selectable: bool) -> Self
Let the pointer select the link’s text and copy it. Off by default: a link is a control, and a press on it must not start a selection.
The Copy menu on a secondary click (on by default).
Sourcepub fn text_style(self, style: TextStyle) -> Self
pub fn text_style(self, style: TextStyle) -> Self
Theme text style; explicit builders below still win.
pub fn typography(self, role: TypographyRole) -> Self
pub fn size(self, size: f32) -> Self
pub fn weight(self, weight: FontWeight) -> Self
pub fn muted(self) -> Self
Sourcepub fn monospace(self) -> Self
pub fn monospace(self) -> Self
Set the text in the monospace family. Spaces and tabs are kept exactly.
pub fn family(self, family: TextFamily) -> Self
pub fn tabular_numbers(self, tabular: bool) -> Self
pub fn tab_size(self, cells: u16) -> Self
Sourcepub fn wrap(self, wrap: bool) -> Self
pub fn wrap(self, wrap: bool) -> Self
Break lines at the container width (default). Without it every line stays whole and the parent clips it.
Sourcepub fn truncate(self, truncate: bool) -> Self
pub fn truncate(self, truncate: bool) -> Self
Keep one line and end it with an ellipsis when it does not fit. Selection and copy still use the whole text.
Sourcepub fn max_lines(self, lines: usize) -> Self
pub fn max_lines(self, lines: usize) -> Self
At most lines visual lines, ending with an ellipsis when the text is longer.
Sourcepub fn show(self, ui: &mut Ui<'_>) -> HyperlinkOutput
pub fn show(self, ui: &mut Ui<'_>) -> HyperlinkOutput
Show the link and get its activation and address.
Trait Implementations§
Source§impl Widget for Hyperlink
impl Widget for Hyperlink
fn ui(self, ui: &mut Ui<'_>) -> Response
Source§fn tooltip(self, text: impl Into<String>) -> TooltipWidget<Self>where
Self: Sized,
fn tooltip(self, text: impl Into<String>) -> TooltipWidget<Self>where
Self: Sized,
ui.add(Button::new("Save").tooltip("Write the file")).Response::menu_selected on the pass it is picked.Source§fn accessible_label(self, label: impl Into<String>) -> Accessible<Self>where
Self: Sized,
fn accessible_label(self, label: impl Into<String>) -> Accessible<Self>where
Self: Sized,
Source§fn accessible_description(
self,
description: impl Into<String>,
) -> Accessible<Self>where
Self: Sized,
fn accessible_description(
self,
description: impl Into<String>,
) -> Accessible<Self>where
Self: Sized,
Source§fn accessible_role(self, role: AccessRole) -> Accessible<Self>where
Self: Sized,
fn accessible_role(self, role: AccessRole) -> Accessible<Self>where
Self: Sized,
role. A custom widget that does
not describe itself becomes a node of this role with the response’s bounds.Auto Trait Implementations§
impl Freeze for Hyperlink
impl RefUnwindSafe for Hyperlink
impl Send for Hyperlink
impl Sync for Hyperlink
impl Unpin for Hyperlink
impl UnsafeUnpin for Hyperlink
impl UnwindSafe for Hyperlink
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.