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§
source§impl Label
impl Label
pub fn new(text: impl Into<WidgetText>) -> Self
pub fn text(&self) -> &str
sourcepub fn wrap(self, wrap: bool) -> Self
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
.
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() {
/* … */
}
source§impl 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.