Struct ComboBox

Source
pub struct ComboBox<T, A = ()> { /* private fields */ }
Expand description

Editable, filtered single-selection control over typed values.

Selecting an enabled option updates a signal installed by Self::bind and invokes the change callback only when its value differs from the current one. Self::selected is read-only configuration and is not mutated internally.

§Examples

use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().option(1, "One").selected(1);
let _ = combo;

Implementations§

Source§

impl<T: Clone + PartialEq + 'static, A: 'static> ComboBox<T, A>

Source

pub fn new() -> Self

Creates an enabled empty combo box with Search... placeholder.

It has no selection, no callback, an empty initial query, and a closed default popup.

§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<&'static str> = ComboBox::new();
let _ = combo;
Source

pub fn placeholder(self, placeholder: impl Into<Binding<String>>) -> Self

Replaces the static or reactive empty-query placeholder.

§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().placeholder("Choose...");
let _ = combo;
Source

pub fn option(self, value: T, label: impl Into<String>) -> Self

Appends an enabled, iconless option.

§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().option(1, "One").option(2, "Two");
let _ = combo;
Source

pub fn combo_option(self, option: ComboBoxOption<T>) -> Self

Appends a fully configured option.

§Examples
use ailloli_ui_widgets::controls::{ComboBox, ComboBoxOption};
let combo: ComboBox<i32> = ComboBox::new()
    .combo_option(ComboBoxOption::new(1, "One").disabled(true));
let _ = combo;
Source

pub fn selected(self, selected: impl Into<Binding<T>>) -> Self

Sets a read-only static or reactive selection and clears writable binding.

Activating another option can still emit on_change, but cannot mutate this selection. If duplicate values exist, the first equal option labels it.

§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().option(1, "One").selected(1);
let _ = combo;
Source

pub fn bind(self, selected: impl Into<Signal<T>>) -> Self

Binds a writable selection signal.

Activating a different enabled option writes the signal before invoking the change callback.

§Examples
use ailloli_ui_runtime::component::State;
use ailloli_ui_widgets::controls::ComboBox;
let selected = State::new(1);
let combo: ComboBox<i32> = ComboBox::new().option(1, "One").bind(selected);
let _ = combo;
Source

pub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self

Sets the static or reactive whole-control disabled state.

Disabled combo boxes are not focusable, ignore events, and close an open popup during layout.

§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().disabled(true);
let _ = combo;
Source

pub fn disabled_signal(self, disabled: Memo<bool>) -> Self

Uses a memo as the reactive whole-control disabled binding.

§Examples
use ailloli_ui_runtime::component::Memo;
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().disabled_signal(Memo::new(|| false));
let _ = combo;
Source

pub fn default_query(self, query: impl Into<String>) -> Self

Sets the initial editable query, stored unchanged.

An empty value derives the initial query from the selected option label; a nonempty value takes precedence. Filtering trims and ASCII-lowercases it.

§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().option(1, "Apple").default_query("app");
let _ = combo;
Source

pub fn default_open(self, open: bool) -> Self

Sets only the popup’s initial open state.

§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().default_open(true);
let _ = combo;
Source

pub fn combo_style(self, style: ComboBoxStyle) -> Self

Replaces the input and popup style without altering explicit layout values.

§Examples
use ailloli_ui_widgets::controls::{ComboBox, ComboBoxStyle};
let combo: ComboBox<i32> = ComboBox::new().combo_style(ComboBoxStyle::default());
let _ = combo;
Source

pub fn combo_size(self, size: ComboBoxSize) -> Self

Re-derives the style from the default theme and requested density.

This overwrites every prior style customization.

§Examples
use ailloli_ui_widgets::controls::{ComboBox, ComboBoxSize};
let combo: ComboBox<i32> = ComboBox::new().combo_size(ComboBoxSize::Compact);
let _ = combo;
Source

pub fn on_change(self, f: impl Fn(T) -> A + 'static) -> Self

Dispatches the application action returned for a changed selection.

Reselecting an equal value, selecting a disabled row, or activating an out-of-range row emits nothing.

§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32, i32> = ComboBox::new().on_change(|value| value);
let _ = combo;
Source

pub fn on_change_ctx(self, f: impl Fn(&mut EventCtx<A>, T) + 'static) -> Self

Handles a changed selection with direct event-context access.

§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().on_change_ctx(|_ctx, _value| {});
let _ = combo;
Source

pub fn width(self, value: impl Into<Length>) -> Self

Sets the trigger layout width in logical pixels or another [Length].

§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().width(240.0);
let _ = combo;
Source

pub fn height(self, value: impl Into<Length>) -> Self

Sets the trigger layout height in logical pixels or another [Length].

§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().height(40.0);
let _ = combo;
Source

pub fn fill_width(self) -> Self

Makes the trigger fill its available horizontal layout space.

§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().fill_width();
let _ = combo;
Source

pub fn flex_grow(self) -> Self

Sets the flex-grow factor to 1.0 without changing layout width.

§Examples
use ailloli_ui_widgets::controls::ComboBox;
let combo: ComboBox<i32> = ComboBox::new().flex_grow();
let _ = combo;

Trait Implementations§

Source§

impl<T: Clone + PartialEq + 'static, A: 'static> Default for ComboBox<T, A>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Clone + PartialEq + 'static, A: 'static> IntoView<A> for ComboBox<T, A>

Source§

fn into_view(self) -> View<A>

Converts configuration into a sized reactive component view.

Source§

impl<T: Clone + PartialEq + 'static, A: 'static> LayoutExt for ComboBox<T, A>

Source§

fn layout_mut(&mut self) -> &mut LayoutStyle

Returns the widget’s mutable declarative size/inset state. Read more

Auto Trait Implementations§

§

impl<T, A> Freeze for ComboBox<T, A>
where T: Freeze,

§

impl<T, A = ()> !RefUnwindSafe for ComboBox<T, A>

§

impl<T, A = ()> !Send for ComboBox<T, A>

§

impl<T, A = ()> !Sync for ComboBox<T, A>

§

impl<T, A> Unpin for ComboBox<T, A>
where T: Unpin,

§

impl<T, A = ()> !UnwindSafe for ComboBox<T, A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, A> FlexItemExt<A> for T
where T: IntoView<A>,

Source§

fn flex_grow(self) -> View<A>

Sets flex-grow weight to one. Read more
Source§

fn flex_grow_by(self, value: f32) -> View<A>

Sets the dimensionless flex-grow weight. Read more
Source§

fn flex_shrink(self, value: f32) -> View<A>

Sets the dimensionless flex-shrink weight. Read more
Source§

fn flex_basis(self, value: impl Into<Length>) -> View<A>

Sets the preferred main-axis flex basis. Read more
Source§

fn align_self(self, value: AlignItems) -> View<A>

Overrides the parent cross-axis alignment for this view. Read more
Source§

fn fill_width(self) -> View<A>

Marks width as parent-fill in the view size hint. Read more
Source§

fn fill_height(self) -> View<A>

Marks height as parent-fill in the view size hint. Read more
Source§

fn fill(self) -> View<A>

Marks both axes as parent-fill in the view size hint. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T, A> IntoViewKeyExt<A> for T
where T: IntoView<A>,

§

fn key(self, key: impl Into<String>) -> View<A>

Converts self, assigns the owned key, and returns the view. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,