pub struct Select { /* private fields */ }Expand description
Picks one option from a list, shown in a field-like trigger. Enter, Space or an arrow key opens the list with the current option focused; arrows move, Enter picks, Escape closes, and focus returns to the field.
Implementations§
Source§impl Select
impl Select
Sourcepub fn new(
selected: Binding<usize>,
options: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn new( selected: Binding<usize>, options: impl IntoIterator<Item = impl Into<String>>, ) -> Self
A select over options; selected holds the zero-based index of the choice.
Sourcepub fn of<T: Clone + PartialEq + 'static>(
value: Binding<T>,
options: impl IntoIterator<Item = (T, impl Into<String>)>,
) -> Self
pub fn of<T: Clone + PartialEq + 'static>( value: Binding<T>, options: impl IntoIterator<Item = (T, impl Into<String>)>, ) -> Self
A select over values of any type, each with the text that shows it: value holds
the value itself, not its position. A value that is not among the options shows
nothing until one is picked.
use ravenrs_reactive::State;
use ravenrs_widgets::{Select, Ui};
#[derive(Clone, PartialEq)]
enum Quality {
Draft,
Final,
}
let quality = State::new(Quality::Final);
let select = Select::of(quality.binding(), [(Quality::Draft, "Draft"), (Quality::Final, "Final")]);
let mut ui = Ui::new(select, ravenrs_style::Theme::raven_dark());
ui.update();Sourcepub fn searchable(self) -> Self
pub fn searchable(self) -> Self
Opens with a search box that filters the options as you type.
Sourcepub fn size(self, size: ButtonSize) -> Self
pub fn size(self, size: ButtonSize) -> Self
Sets the height and text size to line up with a Button of the same size
(Medium by default).
Sourcepub fn label(self, label: impl Into<String>) -> Self
pub fn label(self, label: impl Into<String>) -> Self
The name screen readers announce, such as “Country”. Inside a
crate::FormField, its label is used instead.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Select
impl !Send for Select
impl !Sync for Select
impl !UnwindSafe for Select
impl Freeze for Select
impl Unpin for Select
impl UnsafeUnpin for Select
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
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Adds padding inside the box, in logical pixels.
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Paints a background behind the content.
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
Fixes the width and/or height in logical pixels;
None keeps the content size.