pub struct RadioGroup<T: SelectionItem = StringItem> { /* private fields */ }Expand description
Radio group widget for single-selection
Generic over T: SelectionItem. For simple string selections, use the default
RadioGroup<StringItem> via the choices() builder.
Implementations§
Source§impl RadioGroup<StringItem>
impl RadioGroup<StringItem>
Sourcepub fn new(cx: &mut Context<'_, Self>) -> Self
pub fn new(cx: &mut Context<'_, Self>) -> Self
Create a new radio group for string selections
Use choices() to set the available options.
Sourcepub fn choices(self, choices: Vec<String>) -> Self
pub fn choices(self, choices: Vec<String>) -> Self
Set choices from strings (builder pattern)
This is the backward-compatible API for string-based selections.
Sourcepub fn with_selected_value(self, value: &str) -> Self
pub fn with_selected_value(self, value: &str) -> Self
Set selected value by string (builder pattern)
For use with choices() API.
Sourcepub fn set_selected_value(&mut self, value: &str, cx: &mut Context<'_, Self>)
pub fn set_selected_value(&mut self, value: &str, cx: &mut Context<'_, Self>)
Set selected by string value programmatically
For use with choices() API. Emits Change event if value changes.
Sourcepub fn selected_value(&self) -> &str
pub fn selected_value(&self) -> &str
Get the selected value as a string
Convenience method for string-based radio groups.
Source§impl<T: SelectionItem> RadioGroup<T>
impl<T: SelectionItem> RadioGroup<T>
Sourcepub fn new_with_items(
items: Vec<T>,
selected: T,
cx: &mut Context<'_, Self>,
) -> Self
pub fn new_with_items( items: Vec<T>, selected: T, cx: &mut Context<'_, Self>, ) -> Self
Create a new radio group with items and initial selection
Sourcepub fn with_items(self, items: Vec<T>) -> Self
pub fn with_items(self, items: Vec<T>) -> Self
Set items (builder pattern)
Sourcepub fn with_selected(self, item: T) -> Self
pub fn with_selected(self, item: T) -> Self
Set selected item (builder pattern)
Sourcepub fn with_selected_index(self, index: usize) -> Self
pub fn with_selected_index(self, index: usize) -> Self
Set selected by index (builder pattern)
Sourcepub fn with_enabled(self, enabled: bool) -> Self
pub fn with_enabled(self, enabled: bool) -> Self
Set enabled state (builder pattern)
Sourcepub fn selected_index(&self) -> usize
pub fn selected_index(&self) -> usize
Get the currently selected index
Sourcepub fn set_selected(&mut self, item: T, cx: &mut Context<'_, Self>)
pub fn set_selected(&mut self, item: T, cx: &mut Context<'_, Self>)
Set selected item programmatically
Emits Change event if selection changes.
Sourcepub fn set_selected_index(&mut self, index: usize, cx: &mut Context<'_, Self>)
pub fn set_selected_index(&mut self, index: usize, cx: &mut Context<'_, Self>)
Set selected by index programmatically
Emits Change event if selection changes.
Sourcepub fn focus_handle(&self) -> &FocusHandle
pub fn focus_handle(&self) -> &FocusHandle
Get the focus handle
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if the radio group is enabled
Sourcepub fn set_enabled(&mut self, enabled: bool, cx: &mut Context<'_, Self>)
pub fn set_enabled(&mut self, enabled: bool, cx: &mut Context<'_, Self>)
Set enabled state programmatically
Trait Implementations§
Source§impl<T: SelectionItem> Focusable for RadioGroup<T>
impl<T: SelectionItem> Focusable for RadioGroup<T>
Source§fn focus_handle(&self, _cx: &App) -> FocusHandle
fn focus_handle(&self, _cx: &App) -> FocusHandle
Source§impl<T: SelectionItem> Render for RadioGroup<T>
impl<T: SelectionItem> Render for RadioGroup<T>
impl<T: SelectionItem> EventEmitter<RadioGroupEvent<T>> for RadioGroup<T>
Auto Trait Implementations§
impl<T> Freeze for RadioGroup<T>where
T: Freeze,
impl<T = StringItem> !RefUnwindSafe for RadioGroup<T>
impl<T> Send for RadioGroup<T>where
T: Send,
impl<T> Sync for RadioGroup<T>where
T: Sync,
impl<T> Unpin for RadioGroup<T>where
T: Unpin,
impl<T> UnsafeUnpin for RadioGroup<T>where
T: UnsafeUnpin,
impl<T = StringItem> !UnwindSafe for RadioGroup<T>
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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