Struct egui::containers::ComboBox[][src]

pub struct ComboBox { /* fields omitted */ }
Expand description

A drop-down selection menu with a descriptive label.

egui::ComboBox::from_label( "Select one!")
    .selected_text(format!("{:?}", selected))
    .show_ui(ui, |ui| {
        ui.selectable_value(&mut selected, Enum::First, "First");
        ui.selectable_value(&mut selected, Enum::Second, "Second");
        ui.selectable_value(&mut selected, Enum::Third, "Third");
    }
);

Implementations

Label shown next to the combo box

Without label.

Set the width of the button and menu

What we show as the currently selected value

Show the combo box, with the given ui code for the menu contents.

Returns InnerResponse { inner: None } if the combo box is closed.

Show a list of items with the given selected index.

let alternatives = ["a", "b", "c", "d"];
let mut selected = 2;
egui::ComboBox::from_label( "Select one!").show_index(
    ui,
    &mut selected,
    alternatives.len(),
    |i| alternatives[i].to_owned()
);

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

Performs the conversion.

Performs the conversion.

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.