Skip to main content

RadioGroup

Struct RadioGroup 

Source
pub struct RadioGroup { /* private fields */ }
Expand description

A radio button group widget for single selection

Implementations§

Source§

impl RadioGroup

Source

pub fn new<I, S>(options: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Create a new radio group with options

Source

pub fn selected(self, index: usize) -> Self

Set selected index

Source

pub fn focused(self, focused: bool) -> Self

Set focused state

Source

pub fn disabled(self, disabled: bool) -> Self

Set disabled state

Source

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

Set radio style

Source

pub fn layout(self, layout: RadioLayout) -> Self

Set layout direction

Source

pub fn gap(self, gap: u16) -> Self

Set gap between options

Source

pub fn fg(self, color: Color) -> Self

Set label color

Source

pub fn selected_fg(self, color: Color) -> Self

Set selected indicator color

Source

pub fn selected_index(&self) -> usize

Get selected index

Source

pub fn selected_value(&self) -> Option<&str>

Get selected option value

Source

pub fn is_focused(&self) -> bool

Check if focused

Source

pub fn is_disabled(&self) -> bool

Check if disabled

Source

pub fn select_next(&mut self)

Select next option (wraps around)

Source

pub fn select_prev(&mut self)

Select previous option (wraps around)

Source

pub fn set_focused(&mut self, focused: bool)

Set focus state (mutable)

Source

pub fn set_selected(&mut self, index: usize)

Set selected index (mutable)

Source

pub fn handle_key(&mut self, key: &Key) -> bool

Handle key input, returns true if selection changed

Source§

impl RadioGroup

Source

pub fn element_id(self, id: impl Into<String>) -> Self

Set element ID for CSS selector (#id)

Source

pub fn class(self, class: impl Into<String>) -> Self

Add a CSS class

Source

pub fn classes<I, S>(self, classes: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Add multiple CSS classes

Trait Implementations§

Source§

impl Clone for RadioGroup

Source§

fn clone(&self) -> RadioGroup

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for RadioGroup

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl StyledView for RadioGroup

Source§

fn set_id(&mut self, id: impl Into<String>)

Set element ID
Source§

fn add_class(&mut self, class: impl Into<String>)

Add a CSS class
Source§

fn remove_class(&mut self, class: &str)

Remove a CSS class
Source§

fn toggle_class(&mut self, class: &str)

Toggle a CSS class
Source§

fn has_class(&self, class: &str) -> bool

Check if has class
Source§

impl View for RadioGroup

Source§

fn id(&self) -> Option<&str>

Get element ID (for CSS #id selectors)
Source§

fn classes(&self) -> &[String]

Get CSS classes (for CSS .class selectors)
Source§

fn meta(&self) -> WidgetMeta

Get widget metadata for DOM
Source§

fn render(&self, ctx: &mut RenderContext<'_>)

Render the view
Source§

fn widget_type(&self) -> &'static str

Get widget type name (for CSS type selectors)
Source§

fn children(&self) -> &[Box<dyn View>]

Get child views (for container widgets) Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.