Struct egui::widgets::label::Label

source ·
pub struct Label {
    text: WidgetText,
    wrap: Option<bool>,
    sense: Option<Sense>,
}
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").wrap(false));
ui.label(egui::RichText::new("With formatting").underline());

Fields§

§text: WidgetText§wrap: Option<bool>§sense: Option<Sense>

Implementations§

source§

impl Label

source

pub fn new(text: impl Into<WidgetText>) -> Self

source

pub fn text(&self) -> &str

source

pub fn wrap(self, wrap: bool) -> Self

If true, the text will wrap to stay within the max width of the Ui.

By default Self::wrap will be true in vertical layouts and horizontal layouts with wrapping, and false on non-wrapping horizontal layouts.

Note that any \n in the text will always produce a new line.

You can also use crate::Style::wrap.

source

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() {
    /* … */
}
source§

impl Label

source

pub fn layout_in_ui(self, ui: &mut Ui) -> (Pos2, WidgetTextGalley, Response)

Do layout and position the galley in the ui, without painting it or adding widget info.

Trait Implementations§

source§

impl Widget for Label

source§

fn ui(self, ui: &mut Ui) -> Response

Allocate space, interact, paint, and return a Response. Read more

Auto Trait Implementations§

§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.