Select
ネイティブのポップオーバーに選択肢を表示する、単一または複数選択のピッカーです。
#インポート
quickgui から Select をインポートします。
use quickgui::*;#使い方
let mut state = SelectState::new(items);
state.open(true);
div().child(text(state.selected_label().unwrap_or("Choose")))#構成
Select::rootSelect::triggerSelect::option_partSelect::labelSelect::valueSelect::iconSelect::backdropSelect::portalSelect::positionerSelect::popupSelect::arrowSelect::listSelect::itemSelect::item_textSelect::item_indicatorSelect::groupSelect::group_labelSelect::separatorSelect::scroll_up_arrowSelect::scroll_down_arrow
#API リファレンス
項目を展開すると説明と完全なシグネチャが表示されます。ダッシュは宣言に既定値が記載されていないことを示します。
SelectState
ソースを見るpub fn new(items: impl IntoIterator<Item = PickerItem<T>>) -> Result<Self, PickerError>with_layoutpub fn with_layout(mut self, layout: SelectPopoverLayout) -> Self—
Configures with layout for this part.
pub fn with_layout(mut self, layout: SelectPopoverLayout) -> Selfソースを見るlayoutpub fn layout(&self) -> SelectPopoverLayout—
set_layoutpub fn set_layout(&mut self, layout: SelectPopoverLayout) -> bool—
Configures set layout for this part.
pub fn set_layout(&mut self, layout: SelectPopoverLayout) -> boolソースを見るitemspub fn items(&self) -> &[PickerItem<T>]—
from_labelspub fn from_labels( items: impl IntoIterator<Item = (T, impl Into<Arc<str>>)>, ) -> Result<Self, PickerError>—
Create a select from Base UI's `items` map form, one entry per value and its label. This is the shortest declaration for a select whose options are a fixed value-to-label mapping; [`Self::new`] stays available for options that need stable IDs or disabled rows.
pub fn from_labels( items: impl IntoIterator<Item = (T, impl Into<Arc<str>>)>, ) -> Result<Self, PickerError>ソースを見るselected_source_indexpub fn selected_source_index(&self) -> Option<usize>—
The first selected source index, or `None` when nothing is selected.
pub fn selected_source_index(&self) -> Option<usize>ソースを見るselected_source_indicespub fn selected_source_indices(&self) -> &[usize]—
Every selected source index, ascending, Base UI's `multiple` value array. A single select holds at most one entry; a multiple select holds at most [`MAX_SELECT_VALUES`].
pub fn selected_source_indices(&self) -> &[usize]ソースを見るselected_itemspub fn selected_items(&self) -> impl Iterator<Item = &PickerItem<T>>—
Every selected item, in source order.
pub fn selected_items(&self) -> impl Iterator<Item = &PickerItem<T>>ソースを見るselected_valuespub fn selected_values(&self) -> impl Iterator<Item = &T>—
Every selected value, in source order.
pub fn selected_values(&self) -> impl Iterator<Item = &T>ソースを見るvalue_textpub fn value_text(&self) -> Option<Arc<str>>—
The joined label text a trigger shows, Base UI's `Select.Value`. Returns `None` when nothing is selected, which is when Base UI renders the placeholder.
pub fn value_text(&self) -> Option<Arc<str>>ソースを見るvalue_separatorpub fn value_separator(mut self, separator: impl Into<Arc<str>>) -> Self—
Replace the separator joining a multiple select's value text.
pub fn value_separator(mut self, separator: impl Into<Arc<str>>) -> Selfソースを見るmultiplepub fn multiple(mut self, multiple: bool) -> Self—
Accept more than one value, Base UI's `multiple`. Turning `multiple` off keeps only the first selected value, so the retained set can never disagree with the declared arity.
pub fn multiple(mut self, multiple: bool) -> Selfソースを見るset_multiplepub fn set_multiple(&mut self, multiple: bool) -> bool—
Replace the multiple flag in place, reporting whether anything changed.
pub fn set_multiple(&mut self, multiple: bool) -> boolソースを見るis_multiplepub const fn is_multiple(&self) -> bool—
requiredpub const fn required(mut self, required: bool) -> Self—
Require a value before submission, Base UI's `required`.
pub const fn required(mut self, required: bool) -> Selfソースを見るis_requiredpub const fn is_required(&self) -> bool—
read_onlypub const fn read_only(mut self, read_only: bool) -> Self—
Refuse value changes while staying focusable, Base UI's `readOnly`.
pub const fn read_only(mut self, read_only: bool) -> Selfソースを見るis_read_onlypub const fn is_read_only(&self) -> bool—
modalpub const fn modal(mut self, modal: bool) -> Self—
Contain focus and expect a mounted backdrop while open, Base UI's `modal`.
pub const fn modal(mut self, modal: bool) -> Selfソースを見るis_modalpub const fn is_modal(&self) -> bool—
align_item_with_triggerpub const fn align_item_with_trigger(mut self, align: bool) -> Self—
Open the popup so the selected row overlaps the trigger, Base UI's `alignItemWithTrigger`. QuickGUI offsets the anchored surface by the selected row's distance from the top of the popup plus [`SelectPopoverLayout::trigger_height`], so the row the user is already looking at does not move under the pointer. The native surface still resolves the final side against the display work area.
pub const fn align_item_with_trigger(mut self, align: bool) -> Selfソースを見るaligns_item_with_triggerpub const fn aligns_item_with_trigger(&self) -> bool—
Configures aligns item with trigger for this part.
pub const fn aligns_item_with_trigger(&self) -> boolソースを見るset_pressedpub const fn set_pressed(&mut self, pressed: bool) -> bool—
Record that the trigger is held down, Base UI's `data-pressed`.
pub const fn set_pressed(&mut self, pressed: bool) -> boolソースを見るset_focusedpub const fn set_focused(&mut self, focused: bool) -> bool—
Record trigger focus, and mark the control touched when focus leaves it.
pub const fn set_focused(&mut self, focused: bool) -> boolソースを見るmark_touchedpub const fn mark_touched(&mut self) -> bool—
Mark the control as having been interacted with, Base UI's `data-touched`.
pub const fn mark_touched(&mut self) -> boolソースを見るreset_touchedpub const fn reset_touched(&mut self) -> bool—
Forget that the control was interacted with, for a form that has just been reset. This is the counterpart of [`Self::reset_dirty`]: a value applied from a declaration is not an interaction, so a host that seeds the control reports Base UI's `data-touched` only for what the user really did.
pub const fn reset_touched(&mut self) -> boolソースを見るreset_dirtypub const fn reset_dirty(&mut self) -> bool—
Forget that the value changed, for a form that has just been submitted or reset.
pub const fn reset_dirty(&mut self) -> boolソースを見るis_dirtypub const fn is_dirty(&self) -> bool—
is_touchedpub const fn is_touched(&self) -> bool—
is_focusedpub const fn is_focused(&self) -> bool—
statepub fn state(&self) -> SelectPartState—
A copyable render-state snapshot the application styles from.
pub fn state(&self) -> SelectPartStateソースを見るselected_itempub fn selected_item(&self) -> Option<&PickerItem<T>>—
selected_valuepub fn selected_value(&self) -> Option<&T>—
popover_windowpub const fn popover_window(&self) -> Option<WindowHandle>—
Configures popover window for this part.
pub const fn popover_window(&self) -> Option<WindowHandle>ソースを見るis_openpub const fn is_open(&self) -> bool—
is_disabledpub const fn is_disabled(&self) -> bool—
is_invalidpub const fn is_invalid(&self) -> bool—
set_itemspub fn set_items( &mut self, items: impl IntoIterator<Item = PickerItem<T>>, cx: &mut EventContext, ) -> Result<(), PickerError>—
Replace the complete bounded source atomically and close an obsolete open snapshot.
pub fn set_items( &mut self, items: impl IntoIterator<Item = PickerItem<T>>, cx: &mut EventContext, ) -> Result<(), PickerError>ソースを見るselect_sourcepub fn select_source(&mut self, source_index: usize) -> bool—
Select one source row. A single select replaces its value. A multiple select adds the row, up to [`MAX_SELECT_VALUES`]. A read-only select refuses both.
pub fn select_source(&mut self, source_index: usize) -> boolソースを見るtoggle_sourcepub fn toggle_source(&mut self, source_index: usize) -> bool—
Toggle one source row, Base UI's `multiple` item behavior. A single select clears its value when the already-selected row is chosen again; a multiple select removes just that value.
pub fn toggle_source(&mut self, source_index: usize) -> boolソースを見るis_source_selectedpub fn is_source_selected(&self, source_index: usize) -> bool—
Whether one source row is currently selected.
pub fn is_source_selected(&self, source_index: usize) -> boolソースを見るselect_idpub fn select_id(&mut self, id: impl Into<ElementId>) -> bool—
Configures select id for this part.
pub fn select_id(&mut self, id: impl Into<ElementId>) -> boolソースを見るclear_selectionpub fn clear_selection(&mut self) -> bool—
set_disabledpub fn set_disabled(&mut self, disabled: bool, cx: &mut EventContext) -> bool—
Change disabled state and synchronously request closure of an open native popover.
pub fn set_disabled(&mut self, disabled: bool, cx: &mut EventContext) -> boolソースを見るset_invalidpub fn set_invalid(&mut self, invalid: bool) -> bool—
validation_messagepub fn validation_message(&self) -> Option<&Arc<str>>—
Configures validation message for this part.
pub fn validation_message(&self) -> Option<&Arc<str>>ソースを見るset_validation_messagepub fn set_validation_message(&mut self, message: impl Into<Arc<str>>) -> bool—
Configures set validation message for this part.
pub fn set_validation_message(&mut self, message: impl Into<Arc<str>>) -> boolソースを見るclear_validation_messagepub fn clear_validation_message(&mut self) -> bool—
Configures clear validation message for this part.
pub fn clear_validation_message(&mut self) -> boolソースを見るclosepub fn close(&mut self, cx: &mut EventContext) -> bool—
surface_idpub fn surface_id(id: impl Into<ElementId>) -> ElementId—
option_id_for_sourcepub fn option_id_for_source( &self, id: impl Into<ElementId>, source_index: usize, ) -> Option<ElementId>—
Configures option id for source for this part.
pub fn option_id_for_source( &self, id: impl Into<ElementId>, source_index: usize, ) -> Option<ElementId>ソースを見るlabel_idpub fn label_id(id: impl Into<ElementId>) -> ElementId—
Stable identity of the mounted label part.
pub fn label_id(id: impl Into<ElementId>) -> ElementIdソースを見るvalue_idpub fn value_id(id: impl Into<ElementId>) -> ElementId—
Stable identity of the mounted value part.
pub fn value_id(id: impl Into<ElementId>) -> ElementIdソースを見るicon_idpub fn icon_id(id: impl Into<ElementId>) -> ElementId—
Stable identity of the mounted icon part.
pub fn icon_id(id: impl Into<ElementId>) -> ElementIdソースを見るbackdrop_idpub fn backdrop_id(id: impl Into<ElementId>) -> ElementId—
Stable identity of the optional owner-window backdrop.
pub fn backdrop_id(id: impl Into<ElementId>) -> ElementIdソースを見るarrow_idpub fn arrow_id(id: impl Into<ElementId>) -> ElementId—
Stable identity of the decorative popup arrow.
pub fn arrow_id(id: impl Into<ElementId>) -> ElementIdソースを見るlist_idpub fn list_id(id: impl Into<ElementId>) -> ElementId—
Stable identity of the scrolling option list inside the popup.
pub fn list_id(id: impl Into<ElementId>) -> ElementIdソースを見るscroll_up_arrow_idpub fn scroll_up_arrow_id(id: impl Into<ElementId>) -> ElementId—
Stable identity of the upward scroll affordance.
pub fn scroll_up_arrow_id(id: impl Into<ElementId>) -> ElementIdソースを見るscroll_down_arrow_idpub fn scroll_down_arrow_id(id: impl Into<ElementId>) -> ElementId—
Stable identity of the downward scroll affordance.
pub fn scroll_down_arrow_id(id: impl Into<ElementId>) -> ElementIdソースを見るSelectState::root_with
ソースを見るpub fn root_with(root: Element) -> ElementDecorate the optional application-owned structural wrapper, Base UI's `Select.Root`.
SelectState::root
ソースを見るpub fn root() -> ElementCreate the unstyled root part. Use [`Self::root_with`] to supply an existing element.
SelectState::label_with
ソースを見るpub fn label_with(id: impl Into<ElementId>, label: Element) -> ElementDecorate the caller-owned visible label, Base UI's `Select.Label`. [`Self::trigger_with`] points at this identity, so the label names the control without its text being copied into a second accessible string.
SelectState::label
ソースを見るpub fn label(id: impl Into<ElementId>) -> ElementCreate the unstyled label part. Use [`Self::label_with`] to supply an existing element.
SelectState::value_with
ソースを見るpub fn value_with(id: impl Into<ElementId>, value: Element) -> ElementDecorate the caller-owned value text inside the trigger, Base UI's `Select.Value`. The trigger already exposes the selected value, so this part is hidden from assistive technology and would otherwise be announced twice. Render [`Self::value_text`] inside it, or the placeholder when it returns `None`.
SelectState::value
ソースを見るpub fn value(id: impl Into<ElementId>) -> ElementCreate the unstyled value part. Use [`Self::value_with`] to supply an existing element.
SelectState::icon_with
ソースを見るpub fn icon_with(id: impl Into<ElementId>, icon: Element) -> ElementDecorate the caller-owned trigger affordance, Base UI's `Select.Icon`.
SelectState::icon
ソースを見るpub fn icon(id: impl Into<ElementId>) -> ElementCreate the unstyled icon part. Use [`Self::icon_with`] to supply an existing element.
SelectState::backdrop_with
ソースを見るpub fn backdrop_with(id: impl Into<ElementId>, backdrop: Element) -> ElementDecorate an optional caller-painted owner-window backdrop, Base UI's `Select.Backdrop`. The option surface is a separate native child window that already takes the pointer grab, so this layer exists only for a caller-painted dimming pass. Mount it while [`Self::is_open`] is true, and declare [`Self::modal`] so the intent is inspectable.
SelectState::backdrop
ソースを見るpub fn backdrop(id: impl Into<ElementId>) -> ElementCreate the unstyled backdrop part. Use [`Self::backdrop_with`] to supply an existing element.
SelectState::portal_with
ソースを見るpub fn portal_with( id: impl Into<ElementId>, label: impl Into<Arc<str>>, option_count: usize, multiple: bool, portal: Element, ) -> ElementDecorate the popup boundary, Base UI's `Select.Portal` and `Select.Positioner`. QuickGUI's option surface is its own native window, so the portal, the positioner, and the popup are one element: all three names decorate it identically and QuickGUI resolves its placement against the display work area rather than a parent stacking context.
SelectState::portal
ソースを見るpub fn portal( id: impl Into<ElementId>, label: impl Into<Arc<str>>, option_count: usize, multiple: bool, ) -> ElementCreate the unstyled portal part. Use [`Self::portal_with`] to supply an existing element.
SelectState::positioner_with
ソースを見るpub fn positioner_with( id: impl Into<ElementId>, label: impl Into<Arc<str>>, option_count: usize, multiple: bool, positioner: Element, ) -> ElementDecorate the popup boundary, Base UI's `Select.Positioner`.
SelectState::positioner
ソースを見るpub fn positioner( id: impl Into<ElementId>, label: impl Into<Arc<str>>, option_count: usize, multiple: bool, ) -> ElementCreate the unstyled positioner part. Use [`Self::positioner_with`] to supply an existing element.
SelectState::popup_with
ソースを見るpub fn popup_with( id: impl Into<ElementId>, label: impl Into<Arc<str>>, option_count: usize, multiple: bool, popup: Element, ) -> ElementDecorate the caller-owned option surface, Base UI's `Select.Popup`. QuickGUI applies this to whatever the surface renderer returns, so an application that composes its own in-window list can reuse exactly the semantics the native surface gets.
SelectState::popup
ソースを見るpub fn popup( id: impl Into<ElementId>, label: impl Into<Arc<str>>, option_count: usize, multiple: bool, ) -> ElementCreate the unstyled popup part. Use [`Self::popup_with`] to supply an existing element.
SelectState::arrow_with
ソースを見るpub fn arrow_with(id: impl Into<ElementId>, arrow: Element) -> ElementPosition a caller-owned decorative arrow, Base UI's `Select.Arrow`.
SelectState::arrow
ソースを見るpub fn arrow(id: impl Into<ElementId>) -> ElementCreate the unstyled arrow part. Use [`Self::arrow_with`] to supply an existing element.
SelectState::list_with
ソースを見るpub fn list_with(id: impl Into<ElementId>, option_count: usize, list: Element) -> ElementDecorate the caller-owned scrolling option list, Base UI's `Select.List`. The popup already carries the list-box role, so the inner list is a structural container: it keeps a stable identity and the declared set size without announcing a second list.
SelectState::list
ソースを見るpub fn list(id: impl Into<ElementId>, option_count: usize) -> ElementCreate the unstyled list part. Use [`Self::list_with`] to supply an existing element.
SelectState::item_with
ソースを見るpub fn item_with( row_id: impl Into<ElementId>, label: impl Into<Arc<str>>, state: SelectOptionState, row: Element, ) -> ElementDecorate one caller-owned option row, Base UI's `Select.Item`. `row_id` comes from [`Self::option_id_for_source`], so the row keeps the identity the popup's active-descendant relationship points at.
SelectState::item
ソースを見るpub fn item( row_id: impl Into<ElementId>, label: impl Into<Arc<str>>, state: SelectOptionState, ) -> ElementCreate the unstyled item part. Use [`Self::item_with`] to supply an existing element.
SelectState::item_text_with
ソースを見るpub fn item_text_with(text: Element) -> ElementDecorate one option's visible text, Base UI's `Select.ItemText`. The row already carries the accessible name, so the text is decoration.
SelectState::item_text
ソースを見るpub fn item_text() -> ElementCreate the unstyled item text part. Use [`Self::item_text_with`] to supply an existing element.
SelectState::item_indicator_with
ソースを見るpub fn item_indicator_with(indicator: Element) -> ElementDecorate one option's selected mark, Base UI's `Select.ItemIndicator`. The row already reports selection, so the indicator is hidden from assistive technology. Mount it only while the row is selected, exactly as Base UI does.
SelectState::item_indicator
ソースを見るpub fn item_indicator() -> ElementCreate the unstyled item indicator part. Use [`Self::item_indicator_with`] to supply an existing element.
SelectState::group_with
ソースを見るpub fn group_with(group: Element) -> ElementDecorate a caller-composed option group, Base UI's `Select.Group`.
SelectState::group
ソースを見るpub fn group() -> ElementCreate the unstyled group part. Use [`Self::group_with`] to supply an existing element.
SelectState::group_label_with
ソースを見るpub fn group_label_with(label_id: impl Into<ElementId>, label: Element) -> ElementDecorate a group's visible label, Base UI's `Select.GroupLabel`. Pass the same `label_id` to [`Element::accessibility_labelled_by`] on the group so the two are related without the text being copied.
SelectState::group_label
ソースを見るpub fn group_label(label_id: impl Into<ElementId>) -> ElementCreate the unstyled group label part. Use [`Self::group_label_with`] to supply an existing element.
SelectState::separator_with
ソースを見るpub fn separator_with(separator: Element) -> ElementDecorate a caller-owned divider between option groups, Base UI's `Select.Separator`.
SelectState::separator
ソースを見るpub fn separator() -> ElementCreate the unstyled separator part. Use [`Self::separator_with`] to supply an existing element.
SelectState::trigger_with
ソースを見るpub fn trigger_with( &self, id: impl Into<ElementId>, label: impl Into<Arc<str>>, trigger: Element, ) -> ElementDecorate an application-owned trigger without adding appearance, Base UI's `Select.Trigger`.
SelectState::trigger
ソースを見るpub fn trigger(&self, id: impl Into<ElementId>, label: impl Into<Arc<str>>) -> ElementCreate the unstyled trigger part. Use [`Self::trigger_with`] to supply an existing element.
SelectState::element
ソースを見るpub fn element<V, PopoverRoot, RenderOption, Change>( &self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, label: impl Into<Arc<str>>, access: fn(&mut V) -> &mut SelectState<T>, trigger: Element, popover_root: PopoverRoot, render_option: RenderOption, change: Change, ) -> Element where V: 'static, T: Clone + 'static, PopoverRoot: Fn(SelectListState) -> Element + Clone + 'static, RenderOption: Fn(&PickerItem<T>, SelectOptionState) -> Element + Clone + 'static, Change: Fn(&mut V, T, &mut EventContext) + Clone + 'static,Build the complete unstyled select interaction from caller-owned trigger, popover, and rows. This is the `fn`-pointer entry point: a view that owns one select per field passes `Self::field`. A host that renders many declared selects through one view passes a per-instance [`StateAccessor`] to [`SelectState::element_with`] instead.
SelectState::element_with
ソースを見るpub fn element_with<V, PopoverRoot, RenderOption, Change>( &self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, label: impl Into<Arc<str>>, access: StateAccessor<V, SelectState<T>>, trigger: Element, popover_root: PopoverRoot, render_option: RenderOption, change: Change, ) -> Element where V: 'static, T: Clone + 'static, PopoverRoot: Fn(SelectListState) -> Element + Clone + 'static, RenderOption: Fn(&PickerItem<T>, SelectOptionState) -> Element + Clone + 'static, Change: Fn(&mut V, T, &mut EventContext) + Clone + 'static,Build the select interaction against a per-instance retained-state accessor. Two selects declared by one view stay independent because the accessor, not the view type, decides which [`SelectState`] each registered listener resolves.
SelectState::element_with_trigger
ソースを見るpub fn element_with_trigger<V, PopoverRoot, RenderOption, Change>( &self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, label: impl Into<Arc<str>>, access: fn(&mut V) -> &mut SelectState<T>, trigger: Element, popover_root: PopoverRoot, render_option: RenderOption, change: Change, ) -> Element where V: 'static, T: Clone + 'static, PopoverRoot: Fn(SelectListState, &SelectPopupParts<'_>) -> Element + Clone + 'static, RenderOption: Fn(&PickerItem<T>, SelectOptionState) -> Element + Clone + 'static, Change: Fn(&mut V, T, &mut EventContext) + Clone + 'static,Build the select interaction with access to the framework-owned popup parts. The surface renderer additionally receives [`SelectPopupParts`], whose `scroll_up_arrow_with` and `scroll_down_arrow_with` decorators carry Base UI's hovered scrolling behavior. Every other entry point is this one with a renderer that ignores them.
SelectState::element_with_trigger_accessor
ソースを見るpub fn element_with_trigger_accessor<V, PopoverRoot, RenderOption, Change>( &self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, label: impl Into<Arc<str>>, access: StateAccessor<V, SelectState<T>>, trigger: Element, popover_root: PopoverRoot, render_option: RenderOption, change: Change, ) -> Element where V: 'static, T: Clone + 'static, PopoverRoot: Fn(SelectListState, &SelectPopupParts<'_>) -> Element + Clone + 'static, RenderOption: Fn(&PickerItem<T>, SelectOptionState) -> Element + Clone + 'static, Change: Fn(&mut V, T, &mut EventContext) + Clone + 'static,Build the popup-parts select interaction against a per-instance retained-state accessor.
