Struct egui::widgets::Button [−][src]
pub struct Button { /* fields omitted */ }
Expand description
Clickable button with text.
See also Ui::button
.
if ui.add(egui::Button::new("Click me")).clicked() {
do_stuff();
}
// A greyed-out and non-interactive button:
if ui.add_enabled(false, egui::Button::new("Can't click this")).clicked() {
unreachable!();
}
Implementations
pub fn image_and_text(
texture_id: TextureId,
size: impl Into<Vec2>,
text: impl Into<WidgetText>
) -> Self
pub fn image_and_text(
texture_id: TextureId,
size: impl Into<Vec2>,
text: impl Into<WidgetText>
) -> Self
Creates a button with an image to the left of the text. The size of the image as displayed is defined by the size Vec2 provided.
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.
Replaced by: Button::new(RichText::new(text).color(…))
Replaced by: Button::new(RichText::new(text).text_style(…))
Override background fill color. Note that this will override any on-hover effects. Calling this will also turn on the frame.
Override button stroke. Note that this will override any on-hover effects. Calling this will also turn on the frame.