Pick list -- dropdown selection.
Props
options(list of strings) -- the available choices.selected(string | nil) -- the currently selected value.placeholder(string) -- placeholder text when nothing is selected.width(length) -- widget width. Default: shrink. SeeToddy.Iced.Length.padding(number | map) -- internal padding. SeeToddy.Iced.Padding.text_size(number) -- text size in pixels.font(string | map) -- font specification. SeeToddy.Iced.Font.line_height(number | map) -- text line height.menu_height(number) -- maximum height of the dropdown menu in pixels.text_shaping-- text shaping strategy. SeeToddy.Iced.Shaping.handle(map) -- customise the dropdown handle indicator. Map with atypekey:%{type: "arrow"}-- default arrow (optionalsizein pixels).%{type: "arrow", size: 12}-- arrow with explicit size.%{type: "static", icon: icon_map}-- fixed icon.%{type: "dynamic", closed: icon_map, open: icon_map}-- state-dependent icons.%{type: "none"}-- no handle. Icon maps:%{code_point: "char", size: n, font: font, spacing: n, line_height: n}.
ellipsis(string) -- text ellipsis strategy:"none","start","middle", or"end". Default:"end".menu_style(map) -- inline style for the dropdown menu. Map with optional keys:background,text_color,selected_text_color,selected_background,border,shadow.style--:defaultorStyleMap.t()for custom styling. SeeToddy.Iced.StyleMap.a11y(map) -- accessibility overrides. SeeToddy.Iced.A11y.
Events
%Widget{type: :select, id: id, value: value}-- emitted when an option is selected.%Widget{type: :open, id: id}-- emitted when the dropdown menu is opened (requireson_open: true).%Widget{type: :close, id: id}-- emitted when the dropdown menu is closed (requireson_close: true).
Summary
Functions
Sets accessibility annotations.
Converts this pick list struct to a ui_node() map via the Toddy.Iced.Widget protocol.
Sets the text ellipsis strategy.
Sets the font.
Sets the dropdown handle style.
Sets the text line height.
Sets the maximum dropdown menu height in pixels.
Sets the dropdown menu style overrides.
Creates a new pick list struct with the given options and optional keyword opts.
Enables or disables the close event when the dropdown menu closes.
Enables or disables the open event when the dropdown menu opens.
Sets the internal padding.
Sets the placeholder text.
Sets the currently selected value.
Sets the pick list style. Accepts :default or a StyleMap.
Sets the text shaping strategy.
Sets the text size in pixels.
Sets the pick list width.
Applies keyword options to an existing pick list struct.
Types
@type option() :: {:selected, String.t()} | {:placeholder, String.t()} | {:width, Toddy.Iced.Length.t()} | {:padding, Toddy.Iced.Padding.t()} | {:text_size, number()} | {:font, Toddy.Iced.Font.t()} | {:line_height, number() | map()} | {:menu_height, number()} | {:text_shaping, Toddy.Iced.Shaping.t()} | {:handle, map()} | {:ellipsis, String.t()} | {:menu_style, map()} | {:style, style()} | {:on_open, boolean()} | {:on_close, boolean()} | {:a11y, Toddy.Iced.A11y.t()}
@type style() :: :default | Toddy.Iced.StyleMap.t()
@type t() :: %Toddy.Iced.Widget.PickList{ a11y: Toddy.Iced.A11y.t() | nil, ellipsis: String.t() | nil, font: Toddy.Iced.Font.t() | nil, handle: map() | nil, id: String.t(), line_height: number() | map() | nil, menu_height: number() | nil, menu_style: map() | nil, on_close: boolean() | nil, on_open: boolean() | nil, options: [String.t()], padding: Toddy.Iced.Padding.t() | nil, placeholder: String.t() | nil, selected: String.t() | nil, style: style() | nil, text_shaping: Toddy.Iced.Shaping.t() | nil, text_size: number() | nil, width: Toddy.Iced.Length.t() | nil }
Functions
@spec a11y(pick_list :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()
Sets accessibility annotations.
@spec build(pick_list :: t()) :: Toddy.Iced.ui_node()
Converts this pick list struct to a ui_node() map via the Toddy.Iced.Widget protocol.
Sets the text ellipsis strategy.
@spec font(pick_list :: t(), font :: Toddy.Iced.Font.t()) :: t()
Sets the font.
Sets the dropdown handle style.
Sets the text line height.
Creates a new pick list struct with the given options and optional keyword opts.
Enables or disables the close event when the dropdown menu closes.
Enables or disables the open event when the dropdown menu opens.
@spec padding(pick_list :: t(), padding :: Toddy.Iced.Padding.t()) :: t()
Sets the internal padding.
Sets the placeholder text.
Sets the currently selected value.
Sets the pick list style. Accepts :default or a StyleMap.
@spec text_shaping(pick_list :: t(), text_shaping :: Toddy.Iced.Shaping.t()) :: t()
Sets the text shaping strategy.
Sets the text size in pixels.
@spec width(pick_list :: t(), width :: Toddy.Iced.Length.t()) :: t()
Sets the pick list width.
Applies keyword options to an existing pick list struct.