pub struct DropdownView<State: 'static> { /* private fields */ }Expand description
A declarative dropdown: a dropdown_panel inside
crate::overlay::anchored. See dropdown.
The host is composed fresh in each pass from the props below rather than
retained: AnchoredOverlayView type-erases its content at construction,
so there is no way to reach back into the panel and re-set one of its own
props once it is inside — the same shape crate::menu::MenuView takes.
Implementations§
Source§impl<State: 'static> DropdownView<State>
impl<State: 'static> DropdownView<State>
Sourcepub fn anchor(self, anchor: &OverlayAnchor) -> Self
pub fn anchor(self, anchor: &OverlayAnchor) -> Self
Anchor the panel to the rect anchor carries — the same cell the
dropdown_field writes, which is also what width-matches the panel to
the field.
Sourcepub fn selected(self, selected: Vec<String>) -> Self
pub fn selected(self, selected: Vec<String>) -> Self
Hand the panel the app-confirmed selection (option values).
Sourcepub fn multi(self, multi: bool) -> Self
pub fn multi(self, multi: bool) -> Self
Allow more than one option at a time (singleSelect: false). The
default here is single-select, inverting the reference’s own default
so the simpler mode is the one a caller gets for free.
Sourcepub fn max_selections(self, max: usize) -> Self
pub fn max_selections(self, max: usize) -> Self
Cap a multi-select at max options (maxSelections); 0 is unlimited.
Deselecting is never capped.
Sourcepub fn open(self, open: bool) -> Self
pub fn open(self, open: bool) -> Self
Hand a kept-mounted panel the app’s open flag, so closing it plays the host’s exit ramp instead of vanishing.
Sourcepub fn searchable(self, searchable: bool) -> Self
pub fn searchable(self, searchable: bool) -> Self
Show the search field above the option list (searchEnabled).
Sourcepub fn query(self, query: impl Into<String>) -> Self
pub fn query(self, query: impl Into<String>) -> Self
Hand the panel the app-confirmed filter query. Only rendered when
searchable is set; the filter itself applies
regardless, so an app may drive it from its own field.
Sourcepub fn on_query<F: Fn(&mut State, String) + 'static>(self, on_query: F) -> Self
pub fn on_query<F: Fn(&mut State, String) + 'static>(self, on_query: F) -> Self
Set the query callback: each edit of the search field reports the text
it requests (onSearchChanged).
Sourcepub fn loading(self, loading: bool) -> Self
pub fn loading(self, loading: bool) -> Self
Show the reference’s centered busy row instead of the option list — the panel half of the async poll seam (see the module docs).
Sourcepub fn error(self, error: Option<String>) -> Self
pub fn error(self, error: Option<String>) -> Self
Show a load failure instead of the option list
(m3e_dropdown_menu_panel.dart:148’s _errorMessage).
Sourcepub fn empty_text(self, text: impl Into<String>) -> Self
pub fn empty_text(self, text: impl Into<String>) -> Self
Replace the empty-state message (noItemsFoundText).
Sourcepub fn max_height(self, max_height: f64) -> Self
pub fn max_height(self, max_height: f64) -> Self
Cap the panel’s height, past which it scrolls (maxHeight).
Sourcepub fn side(self, side: OverlaySide) -> Self
pub fn side(self, side: OverlaySide) -> Self
Set the side the panel opens on (bottom by default). The reference’s
expandDirection up/down map onto this; its auto is the anchored
host’s own collision flip, which is on by default.
Sourcepub fn align(self, align: OverlayAlign) -> Self
pub fn align(self, align: OverlayAlign) -> Self
Set the cross-axis alignment (start by default, the edge the
reference’s CompositedTransformFollower pins).
Sourcepub fn offset(self, offset: f64) -> Self
pub fn offset(self, offset: f64) -> Self
Set the gap between field and panel (marginTop, 4dp by default).
Sourcepub fn on_open<F: Fn(&mut State, bool) + 'static>(self, on_open: F) -> Self
pub fn on_open<F: Fn(&mut State, bool) + 'static>(self, on_open: F) -> Self
Set the open callback. Fired with false by a light dismiss, by Escape
once the host holds focus, and by a single-select activation — the
reference’s _selectSingleItem closes the dropdown after picking.
Trait Implementations§
Source§impl<State: 'static> View<State> for DropdownView<State>
impl<State: 'static> View<State> for DropdownView<State>
Source§type Element = AnchoredOverlayWidget
type Element = AnchoredOverlayWidget
Source§fn build(&self, ctx: &mut BuildCtx<'_>) -> AnchoredOverlayWidget
fn build(&self, ctx: &mut BuildCtx<'_>) -> AnchoredOverlayWidget
Source§fn rebuild(
&self,
prev: &Self,
element: &mut AnchoredOverlayWidget,
ctx: &mut BuildCtx<'_>,
) -> ChangeFlags
fn rebuild( &self, prev: &Self, element: &mut AnchoredOverlayWidget, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags
prev (the previous view of the same type) against the live
element, mutating it in place and reporting what changed.Auto Trait Implementations§
impl<State> !RefUnwindSafe for DropdownView<State>
impl<State> !Send for DropdownView<State>
impl<State> !Sync for DropdownView<State>
impl<State> !UnwindSafe for DropdownView<State>
impl<State> Freeze for DropdownView<State>
impl<State> Unpin for DropdownView<State>
impl<State> UnsafeUnpin for DropdownView<State>where
Rc<dyn Fn(&mut State, Vec<String>)>: UnsafeUnpin,
Option<Rc<dyn Fn(&mut State, bool)>>: UnsafeUnpin,
Option<Rc<dyn Fn(&mut State, String)>>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Source§impl<State, V> ViewSeq<State, One> for Vwhere
State: 'static,
V: View<State>,
impl<State, V> ViewSeq<State, One> for Vwhere
State: 'static,
V: View<State>,
Source§fn extend_views(self, out: &mut Vec<AnyView<State>>)
fn extend_views(self, out: &mut Vec<AnyView<State>>)
out — erasing each
with AnyView::new (a no-op for an element already an AnyView).