Struct Select

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

Controlled single-selection trigger over typed values.

Selecting an enabled option updates a signal installed by Self::bind and invokes the 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::Select;
let select: Select<i32> = Select::new().option(1, "One").selected(1);
let _ = select;

Implementations§

Source§

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

Source

pub fn new() -> Self

Creates an enabled empty select with Select option placeholder.

It has no selection or callback, prefers bottom placement, and starts closed.

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

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

Replaces the static or reactive no-selection label.

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

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

Appends an enabled, iconless option.

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

pub fn select_option(self, option: SelectOption<T>) -> Self

Appends a fully configured option.

§Examples
use ailloli_ui_widgets::controls::{Select, SelectOption};
let select: Select<i32> = Select::new()
    .select_option(SelectOption::new(1, "One").disabled(true));
let _ = select;
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 value may emit the callback but cannot mutate this selection. Duplicate values resolve to the first equal option.

§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32> = Select::new().option(1, "One").selected(1);
let _ = select;
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::Select;
let select: Select<i32> = Select::new().option(1, "One").bind(State::new(1));
let _ = select;
Source

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

Sets static or reactive whole-control disabled state.

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

§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32> = Select::new().disabled(true);
let _ = select;
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::Select;
let select: Select<i32> = Select::new().disabled_signal(Memo::new(|| false));
let _ = select;
Source

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

Sets only the retained popup’s initial open state.

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

pub fn popup_placement(self, placement: PopupPlacement) -> Self

Sets the preferred PopupPlacement::Top or PopupPlacement::Bottom side.

Runtime geometry may clamp the resulting rectangle; this builder does not enable automatic side flipping.

§Examples
use ailloli_ui_widgets::controls::{PopupPlacement, Select};
let select: Select<i32> = Select::new().popup_placement(PopupPlacement::Top);
let _ = select;
Source

pub fn select_style(self, style: SelectStyle) -> Self

Replaces trigger and popup style without altering explicit layout values.

§Examples
use ailloli_ui_widgets::controls::{Select, SelectStyle};
let select: Select<i32> = Select::new().select_style(SelectStyle::default());
let _ = select;
Source

pub fn select_size(self, size: SelectSize) -> Self

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

This overwrites every previous select-style customization.

§Examples
use ailloli_ui_widgets::controls::{Select, SelectSize};
let select: Select<i32> = Select::new().select_size(SelectSize::Compact);
let _ = select;
Source

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

Dispatches the application action returned for a changed selection.

Equal values, disabled rows, and out-of-range indices emit nothing.

§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32, i32> = Select::new().on_change(|value| value);
let _ = select;
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::Select;
let select: Select<i32> = Select::new().on_change_ctx(|_ctx, _value| {});
let _ = select;
Source

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

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

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

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

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

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

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

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

§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32> = Select::new().min_width(120.0);
let _ = select;
Source

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

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

§Examples
use ailloli_ui_widgets::controls::Select;
let select: Select<i32> = Select::new().max_width(360.0);
let _ = select;
Source

pub fn fill_width(self) -> Self

Makes the trigger fill available horizontal layout space.

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

pub fn flex_grow(self) -> Self

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

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

Trait Implementations§

Source§

impl<T: Clone + PartialEq + 'static, A: 'static> Default for Select<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 Select<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 Select<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 Select<T, A>
where T: Freeze,

§

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

§

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

§

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

§

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

§

impl<T, A = ()> !UnwindSafe for Select<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,