pub struct RadioGroupState { /* private fields */ }Expand description
Retained exclusive selection and focus for one rendered radio group.
Tab enters at the selected option, or the first enabled option when nothing is selected. Arrow keys select and focus the next enabled option, wrapping at either end. Space/Enter or a pointer click select without deselecting an already selected option. Disabled options are skipped. Application value updates preserve a focused option until Tab exits; reentry uses the selection.
Implementations§
Source§impl RadioGroupState
impl RadioGroupState
pub fn new( items: impl IntoIterator<Item = RadioItem>, cx: &mut Context<'_, Self>, ) -> Self
Sourcepub fn default_value(self, value: impl AsRef<str>) -> Self
pub fn default_value(self, value: impl AsRef<str>) -> Self
Selects an enabled value before the state is first rendered. An unknown or disabled value leaves the group unselected.
pub fn items(&self) -> &[RadioItem]
pub fn selected_index(&self) -> Option<usize>
pub fn selected_item(&self) -> Option<&RadioItem>
Sourcepub fn set_selected_value(
&mut self,
value: Option<&str>,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> bool
pub fn set_selected_value( &mut self, value: Option<&str>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> bool
Sets or clears the selected value without emitting Change or moving focus.
Unknown or disabled options are rejected without changing the selection. Returns whether the value was accepted, including an unchanged value. Application updates remain available while the group itself is disabled.
pub fn is_disabled(&self) -> bool
Sourcepub fn option_focus_handle(&self, index: usize) -> &FocusHandle
pub fn option_focus_handle(&self, index: usize) -> &FocusHandle
The stable focus handle of an option in this state’s fixed collection.
Sourcepub fn set_disabled(
&mut self,
disabled: bool,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_disabled( &mut self, disabled: bool, window: &mut Window, cx: &mut Context<'_, Self>, )
Disables the group while retaining its value. An option already holding focus stays in the focus tree so Tab/Shift-Tab can leave the group.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RadioGroupState
impl !UnwindSafe for RadioGroupState
impl Forget for RadioGroupState
impl Freeze for RadioGroupState
impl Move for RadioGroupState
impl Send for RadioGroupState
impl Sync for RadioGroupState
impl Unpin for RadioGroupState
impl UnsafeUnpin for RadioGroupState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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