pub struct Select { /* private fields */ }Expand description
A select/dropdown field.
Implementations§
Source§impl Select
impl Select
Sourcepub fn new(id: impl Into<String>, label: impl Into<String>) -> Self
pub fn new(id: impl Into<String>, label: impl Into<String>) -> Self
Creates a new select field.
Sourcepub fn option(
self,
value: impl Into<String>,
display: impl Into<String>,
) -> Self
pub fn option( self, value: impl Into<String>, display: impl Into<String>, ) -> Self
Adds an option to the select.
Sourcepub fn options(
self,
options: Vec<(impl Into<String>, impl Into<String>)>,
) -> Self
pub fn options( self, options: Vec<(impl Into<String>, impl Into<String>)>, ) -> Self
Adds multiple options at once.
Sourcepub fn initial_value(self, value: &str) -> Self
pub fn initial_value(self, value: &str) -> Self
Sets the initial selected value.
Trait Implementations§
Source§impl Field for Select
impl Field for Select
Source§fn render(&self, area: Rect, buf: &mut Buffer, focused: bool, style: &FormStyle)
fn render(&self, area: Rect, buf: &mut Buffer, focused: bool, style: &FormStyle)
Renders the field to the buffer.
Source§fn handle_input(&mut self, event: &KeyEvent) -> bool
fn handle_input(&mut self, event: &KeyEvent) -> bool
Handles keyboard input. Returns true if the input was consumed.
Source§fn validate(&self) -> Result<(), Vec<ValidationError>>
fn validate(&self) -> Result<(), Vec<ValidationError>>
Validates the field and returns any errors.
Source§fn is_required(&self) -> bool
fn is_required(&self) -> bool
Returns whether this field is required.
Auto Trait Implementations§
impl Freeze for Select
impl RefUnwindSafe for Select
impl Send for Select
impl Sync for Select
impl Unpin for Select
impl UnwindSafe 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more