Skip to main content

Select

Struct Select 

Source
pub struct Select<'a, T, F = fn(&T) -> String>
where 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>

Source

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>
where F: Fn(&T) -> String,

Source

pub fn render_option<G>(self, render_fn: G) -> Select<'a, T, G>
where G: Fn(&T) -> String,

Set a custom option renderer.

Source

pub fn placeholder(self, placeholder: &'a str) -> Self

Set the placeholder text.

Source

pub fn label(self, label: &'a str) -> Self

Set the label (border title).

Source

pub fn style(self, style: SelectStyle) -> Self

Set the style.

Source

pub fn focus_id(self, id: FocusId) -> Self

Set the focus ID.

Source

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.

Source

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 to
  • anchor - The area of the closed select box (dropdown positions below this)
  • screen - The full screen area (for bounds checking)
Source

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>

§

impl<'a, T, F> Send for Select<'a, T, F>
where F: Send, T: Sync,

§

impl<'a, T, F> Sync for Select<'a, T, F>
where F: Sync, T: Sync,

§

impl<'a, T, F> Unpin for Select<'a, T, F>
where F: Unpin,

§

impl<'a, T, F> UnwindSafe for Select<'a, T, F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.