pub struct Label { /* private fields */ }Expand description
Static text.
Usually it is more convenient to use Ui::label.
ui.label("Equivalent");
ui.add(egui::Label::new("Equivalent"));
ui.add(egui::Label::new("With Options").truncate());
ui.label(egui::RichText::new("With formatting").underline());For full control of the text you can use crate::text::LayoutJob
as argument to Self::new.
Implementations§
Source§impl Label
impl Label
pub fn new(text: impl Into<WidgetText>) -> Self
pub fn text(&self) -> &str
Sourcepub fn wrap_mode(self, wrap_mode: TextWrapMode) -> Self
pub fn wrap_mode(self, wrap_mode: TextWrapMode) -> Self
Set the wrap mode for the text.
By default, crate::Ui::wrap_mode will be used, which can be overridden with crate::Style::wrap_mode.
Note that any \n in the text will always produce a new line.
Sourcepub fn wrap(self) -> Self
pub fn wrap(self) -> Self
Set Self::wrap_mode to TextWrapMode::Wrap.
Sourcepub fn extend(self) -> Self
pub fn extend(self) -> Self
Set Self::wrap_mode to TextWrapMode::Extend,
disabling wrapping and truncating, and instead expanding the parent Ui.
Sourcepub fn halign(self, align: Align) -> Self
pub fn halign(self, align: Align) -> Self
Sets the horizontal alignment of the Label to the given Align value.
Sourcepub fn selectable(self, selectable: bool) -> Self
pub fn selectable(self, selectable: bool) -> Self
Can the user select the text with the mouse?
Overrides crate::style::Interaction::selectable_labels.
Sourcepub fn sense(self, sense: Sense) -> Self
pub fn sense(self, sense: Sense) -> Self
Make the label respond to clicks and/or drags.
By default, a label is inert and does not respond to click or drags. By calling this you can turn the label into a button of sorts. This will also give the label the hover-effect of a button, but without the frame.
if ui.add(Label::new("click me").sense(Sense::click())).clicked() {
/* … */
}Sourcepub fn show_tooltip_when_elided(self, show: bool) -> Self
pub fn show_tooltip_when_elided(self, show: bool) -> Self
Show the full text when hovered, if the text was elided.
By default, this is true.
ui.add(Label::new("some text").show_tooltip_when_elided(false))
.on_hover_text("completely different text");Trait Implementations§
Auto Trait Implementations§
impl Freeze for Label
impl RefUnwindSafe for Label
impl Send for Label
impl Sync for Label
impl Unpin for Label
impl UnwindSafe for Label
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more