pub struct Label {
text: WidgetText,
wrap_mode: Option<TextWrapMode>,
sense: Option<Sense>,
selectable: Option<bool>,
halign: Option<Align>,
}
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
.
Fields§
§text: WidgetText
§wrap_mode: Option<TextWrapMode>
§sense: Option<Sense>
§selectable: Option<bool>
§halign: Option<Align>
Implementations§
§impl Label
impl Label
pub fn new(text: impl Into<WidgetText>) -> Label
pub fn text(&self) -> &str
pub 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.
pub fn wrap(self) -> Label
pub fn wrap(self) -> Label
Set Self::wrap_mode
to TextWrapMode::Wrap
.
pub 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
.
pub 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.
pub 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
.
pub 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() {
/* … */
}
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> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request