pub struct ComboBox { /* private fields */ }Expand description
Dropdown whose closed face is a Label (text and/or image).
let current = Label::new("Tokyo Night", None);
ComboBox::new("theme", current).width(200.0).show_ui(ui, |ui| {
ui.label("Tokyo Night Light");
});Implementations§
Source§impl ComboBox
impl ComboBox
Sourcepub fn new(id_salt: impl Hash + Debug, selected_item: Label) -> Self
pub fn new(id_salt: impl Hash + Debug, selected_item: Label) -> Self
Create a combo box keyed by id_salt, showing selected_item on the button.
Sourcepub fn visuals(self, visuals: ComboBoxVisuals) -> Self
pub fn visuals(self, visuals: ComboBoxVisuals) -> Self
Override the chrome that would otherwise come from the installed theme.
Sourcepub fn label(self, label: impl Into<WidgetText>) -> Self
pub fn label(self, label: impl Into<WidgetText>) -> Self
Optional caption painted to the left of the button.
Sourcepub fn width(self, width: f32) -> Self
pub fn width(self, width: f32) -> Self
Set the exact width of the combo box button. If not set, the width adapts to the content, icon, and minimum width.
Sourcepub fn popup_max_height(self, height: f32) -> Self
pub fn popup_max_height(self, height: f32) -> Self
Set the maximum height of the popup menu.
Default is ui.spacing().combo_height.
Sourcepub fn icon(
self,
icon_fn: impl FnOnce(&Ui, Rect, &WidgetVisuals, bool) + 'static,
) -> Self
pub fn icon( self, icon_fn: impl FnOnce(&Ui, Rect, &WidgetVisuals, bool) + 'static, ) -> Self
Replace the default disclosure triangle with a custom painter.
The bool argument is true while the popup is open.
Sourcepub fn wrap_mode(self, wrap_mode: TextWrapMode) -> Self
pub fn wrap_mode(self, wrap_mode: TextWrapMode) -> Self
Set the wrap mode for the selected text displayed in the button.
Sourcepub fn close_behavior(self, close_behavior: PopupCloseBehavior) -> Self
pub fn close_behavior(self, close_behavior: PopupCloseBehavior) -> Self
How the popup closes. Default: PopupCloseBehavior::CloseOnClick.
Auto Trait Implementations§
impl !RefUnwindSafe for ComboBox
impl !Send for ComboBox
impl !Sync for ComboBox
impl !UnwindSafe for ComboBox
impl Freeze for ComboBox
impl Unpin for ComboBox
impl UnsafeUnpin for ComboBox
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more