pub struct Label { /* private fields */ }egui only.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>) -> Label
pub fn text(&self) -> &str
Sourcepub fn wrap_mode(self, wrap_mode: TextWrapMode) -> Label
pub fn wrap_mode(self, wrap_mode: TextWrapMode) -> Label
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) -> Label
pub fn wrap(self) -> Label
Set Self::wrap_mode to TextWrapMode::Wrap.
Sourcepub fn extend(self) -> Label
pub fn extend(self) -> Label
Set Self::wrap_mode to TextWrapMode::Extend,
disabling wrapping and truncating, and instead expanding the parent Ui.
Sourcepub fn halign(self, align: Align) -> Label
pub fn halign(self, align: Align) -> Label
Sets the horizontal alignment of the Label to the given Align value.
Sourcepub fn selectable(self, selectable: bool) -> Label
pub fn selectable(self, selectable: bool) -> Label
Can the user select the text with the mouse?
Overrides crate::style::Interaction::selectable_labels.
Sourcepub fn sense(self, sense: Sense) -> Label
pub fn sense(self, sense: Sense) -> Label
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) -> Label
pub fn show_tooltip_when_elided(self, show: bool) -> Label
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 Forget for Label
impl Freeze for Labelwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const ArcInner<RichText> is !null: Freeze,
PhantomData<ArcInner<RichText>>: Freeze,
*const ArcInner<LayoutJob> is !null: Freeze,
PhantomData<ArcInner<LayoutJob>>: Freeze,
*const ArcInner<Galley> is !null: Freeze,
PhantomData<ArcInner<Galley>>: Freeze,
impl Move for Label
impl RefUnwindSafe for Label
impl Send for Label
impl Sync for Label
impl Unpin for Label
impl UnsafeUnpin for Labelwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<RichText> is !null: UnsafeUnpin,
PhantomData<ArcInner<RichText>>: UnsafeUnpin,
*const ArcInner<LayoutJob> is !null: UnsafeUnpin,
PhantomData<ArcInner<LayoutJob>>: UnsafeUnpin,
*const ArcInner<Galley> is !null: UnsafeUnpin,
PhantomData<ArcInner<Galley>>: UnsafeUnpin,
impl UnwindSafe for Labelwhere
RawVecInner: UnwindSafe,
Arc<RichText>: UnwindSafe,
Arc<LayoutJob>: UnwindSafe,
Arc<Galley>: UnwindSafe,
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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