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").wrap(false));
ui.label(egui::RichText::new("With formatting").underline());
Implementations
sourceimpl Label
impl Label
pub fn new(text: impl Into<WidgetText>) -> Label
pub fn text(&self) -> &str
sourcepub fn wrap(self, wrap: bool) -> Label
pub fn wrap(self, wrap: bool) -> Label
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.
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() {
/* … */
}
sourceimpl Label
impl Label
sourcepub fn layout_in_ui(self, ui: &mut Ui) -> (Pos2, WidgetTextGalley, Response)
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
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more