pub struct Select<'a, T, F = fn(&T) -> String>{ /* private fields */ }Expand description
Select widget - dropdown select box.
A dropdown select component that renders as a compact closed state and opens a popup overlay with selectable options when activated.
Implementations§
Source§impl<'a, T: Display> Select<'a, T, fn(&T) -> String>
impl<'a, T: Display> Select<'a, T, fn(&T) -> String>
Sourcepub fn new(options: &'a [T], state: &'a SelectState) -> Self
pub fn new(options: &'a [T], state: &'a SelectState) -> Self
Create a new select widget with default option rendering.
Source§impl<'a, T, F> Select<'a, T, F>
impl<'a, T, F> Select<'a, T, F>
Sourcepub fn render_option<G>(self, render_fn: G) -> Select<'a, T, G>
pub fn render_option<G>(self, render_fn: G) -> Select<'a, T, G>
Set a custom option renderer.
Sourcepub fn placeholder(self, placeholder: &'a str) -> Self
pub fn placeholder(self, placeholder: &'a str) -> Self
Set the placeholder text.
Sourcepub fn style(self, style: SelectStyle) -> Self
pub fn style(self, style: SelectStyle) -> Self
Set the style.
Sourcepub fn render_stateful(
self,
frame: &mut Frame<'_>,
area: Rect,
) -> ClickRegion<SelectAction>
pub fn render_stateful( self, frame: &mut Frame<'_>, area: Rect, ) -> ClickRegion<SelectAction>
Render the closed select box and return click region.
This renders the compact closed state of the select box.
Call render_dropdown separately when the dropdown is open.
Sourcepub fn render_dropdown(
&self,
frame: &mut Frame<'_>,
anchor: Rect,
screen: Rect,
) -> Vec<ClickRegion<SelectAction>>
pub fn render_dropdown( &self, frame: &mut Frame<'_>, anchor: Rect, screen: Rect, ) -> Vec<ClickRegion<SelectAction>>
Render the dropdown overlay.
Call this when state.is_open is true. Returns click regions for each option.
§Arguments
frame- The frame to render toanchor- The area of the closed select box (dropdown positions below this)screen- The full screen area (for bounds checking)
Sourcepub fn render_to_buffer(
self,
area: Rect,
buf: &mut Buffer,
) -> ClickRegion<SelectAction>
pub fn render_to_buffer( self, area: Rect, buf: &mut Buffer, ) -> ClickRegion<SelectAction>
Render the select box using Buffer (Widget-style rendering).
This is useful when you need to render without a Frame reference.
Auto Trait Implementations§
impl<'a, T, F> Freeze for Select<'a, T, F>where
F: Freeze,
impl<'a, T, F> RefUnwindSafe for Select<'a, T, F>where
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, F> Send for Select<'a, T, F>
impl<'a, T, F> Sync for Select<'a, T, F>
impl<'a, T, F> Unpin for Select<'a, T, F>where
F: Unpin,
impl<'a, T, F> UnwindSafe for Select<'a, T, F>where
F: UnwindSafe,
T: RefUnwindSafe,
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