Skip to main content

Module select

Module select 

Source
Available on crate feature select only.
Expand description

A dropdown for choosing one value from a list.

The select opens and closes its own list, so the app only handles the chosen value. The list floats on the shared anchored layer in the menu look, with a check mark on the selected option. Escape or a click outside closes it.

A long list shows MAX_VISIBLE_ROWS rows and scrolls, with a scrollbar, and is never taller than the room the window has. It opens with the selected option in the middle, and the highlight stays in view as the keys move it. A list that fits looks as it always has.

An enabled select takes keyboard focus from iced’s focus operations, such as a dialog’s Tab order, and rings while focused. Space, Enter or ArrowDown then opens the list with the selected option highlighted. In the open list the arrow keys, Page Up, Page Down, Home and End move the highlight, Space or Enter chooses it and closes the list, and Tab closes it and moves on. Typing letters moves the highlight to the first option starting with them.

searchable adds a search field that filters the options as you type, and on_custom lets the user enter a value that is not in the list. For typed values such as times, editable makes the closed control the text field, prefer_custom lets the typed text win over the first match, commit_on_leave enters it on Tab or a press elsewhere, and pass_through lets that press reach what is under it.

The open list reports itself to operations with list_id and its search field with search_id, and reports the lines it draws itself (an offered value, the not-valid text, an empty list) as text, so tests can find them.

Re-exports§

pub use crate::primitives::input::Shortcut;
pub use crate::primitives::input::Shortcuts;

Structs§

Select
A select builder. Convert it into an Element to render.

Enums§

Action
What a select keyboard shortcut does.

Constants§

DEFAULT_EMPTY
Shown when the search matches no option.
DEFAULT_NOT_VALID
Shown when the app turns a typed value down.
HEIGHT
Height of the closed select in logical pixels.
MAX_VISIBLE_ROWS
Rows the open list shows before it scrolls, unless max_visible_rows says otherwise.
NO_OPTIONS
Shown in the open list of a select with no options.
TYPE_AHEAD_PAUSE
How long a pause in typing starts a new type-ahead search.

Functions§

default_keymap
The default select shortcuts:
list_id
The id of the open list of a select, reported to operations so tests can find it. Only one list is open at a time.
search_id
The id of the search field in the open list of a select.
select
Creates a select over options, showing selected when it is set. Options are labelled with their Display text. selected need not be one of options, such as a typed time off the half hours: the field shows it, and the open list checks nothing.
style
The iced pick list style for a status.