pub struct Button { /* private fields */ }
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

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.

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.

Make this a small button, suitable for embedding into text.

Turn off the frame

By default, buttons senses clicks. Change this to a drag-button with Sense::drag().

Trait Implementations

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more