pub struct ToggleGroup<T: Clone + PartialEq + 'static> { /* private fields */ }Expand description
A toggle group component for selecting one or multiple options
§Example
use gpuikit::elements::toggle_group::{ToggleGroupMode, toggle_group, toggle_option};
// Single-select mode (default)
let single = toggle_group(
"alignment",
vec![
toggle_option("left", "Left"),
toggle_option("center", "Center"),
toggle_option("right", "Right"),
],
).selected(vec!["center"]);
// Multi-select mode
let multi = toggle_group(
"features",
vec![
toggle_option("bold", "B"),
toggle_option("italic", "I"),
toggle_option("underline", "U"),
],
).mode(ToggleGroupMode::Multiple)
.selected(vec!["bold", "italic"]);Implementations§
Source§impl<T: Clone + PartialEq + 'static> ToggleGroup<T>
impl<T: Clone + PartialEq + 'static> ToggleGroup<T>
Sourcepub fn new(id: impl Into<ElementId>, options: Vec<ToggleOption<T>>) -> Self
pub fn new(id: impl Into<ElementId>, options: Vec<ToggleOption<T>>) -> Self
Create a new toggle group with an ID and options
Sourcepub fn mode(self, mode: ToggleGroupMode) -> Self
pub fn mode(self, mode: ToggleGroupMode) -> Self
Set the selection mode (single or multiple)
Sourcepub fn selected_value(self, value: T) -> Self
pub fn selected_value(self, value: T) -> Self
Set a single selected value (convenience for single-select mode)
Sourcepub fn get_selected(&self) -> &[T]
pub fn get_selected(&self) -> &[T]
Get the currently selected values
Sourcepub fn is_value_selected(&self, value: &T) -> bool
pub fn is_value_selected(&self, value: &T) -> bool
Check if a value is selected
Sourcepub fn set_selected(&mut self, values: Vec<T>, cx: &mut Context<'_, Self>)
pub fn set_selected(&mut self, values: Vec<T>, cx: &mut Context<'_, Self>)
Set the selected values programmatically
Trait Implementations§
Source§impl<T: Clone + PartialEq + 'static> ControlSized for ToggleGroup<T>
impl<T: Clone + PartialEq + 'static> ControlSized for ToggleGroup<T>
Source§impl<T: Clone + PartialEq + 'static> Disableable for ToggleGroup<T>
impl<T: Clone + PartialEq + 'static> Disableable for ToggleGroup<T>
impl<T: Clone + PartialEq + 'static> EventEmitter<ToggleGroupChanged<T>> for ToggleGroup<T>
Source§impl<T: Clone + PartialEq + 'static> Orientable for ToggleGroup<T>
impl<T: Clone + PartialEq + 'static> Orientable for ToggleGroup<T>
Source§fn orientation(self, orientation: Orientation) -> Self
fn orientation(self, orientation: Orientation) -> Self
Set the orientation of this element.
Source§fn horizontal(self) -> Self
fn horizontal(self) -> Self
Set this element to horizontal orientation.
Auto Trait Implementations§
impl<T> Freeze for ToggleGroup<T>
impl<T> RefUnwindSafe for ToggleGroup<T>
impl<T> Send for ToggleGroup<T>
impl<T> Sync for ToggleGroup<T>
impl<T> Unpin for ToggleGroup<T>
impl<T> UnsafeUnpin for ToggleGroup<T>
impl<T> UnwindSafe for ToggleGroup<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
Mutably borrows from an owned value. Read more
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> ⓘ
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