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

pub struct ComboBox { /* fields omitted */ }

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

impl ComboBox[src]

pub fn from_label(label: impl Into<Label>) -> Self[src]

Label shown next to the combo box

pub fn from_id_source(id_source: impl Hash) -> Self[src]

Without label.

pub fn width(self, width: f32) -> Self[src]

Set the width of the button and menu

pub fn selected_text(self, selected_text: impl ToString) -> Self[src]

What we show as the currently selected value

pub fn show_ui(
    self,
    ui: &mut Ui,
    menu_contents: impl FnOnce(&mut Ui)
) -> Response
[src]

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

pub fn show_index(
    self,
    ui: &mut Ui,
    selected: &mut usize,
    len: usize,
    get: impl Fn(usize) -> String
) -> Response
[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.