pub struct ButtonGroup { /* private fields */ }Expand description
An expressive row with controlled selection and a Material menu for items that do not fit. Arrow keys move focus without changing selection.
Implementations§
Source§impl ButtonGroup
impl ButtonGroup
Sourcepub fn new(
id: impl Into<ElementId>,
label: impl Into<SharedString>,
items: impl IntoIterator<Item = ButtonGroupItem>,
) -> ButtonGroup
pub fn new( id: impl Into<ElementId>, label: impl Into<SharedString>, items: impl IntoIterator<Item = ButtonGroupItem>, ) -> ButtonGroup
Creates a standard button group with an element id, accessible label, and items.
Sourcepub fn connected(
id: impl Into<ElementId>,
label: impl Into<SharedString>,
items: impl IntoIterator<Item = ButtonGroupItem>,
) -> ButtonGroup
pub fn connected( id: impl Into<ElementId>, label: impl Into<SharedString>, items: impl IntoIterator<Item = ButtonGroupItem>, ) -> ButtonGroup
Creates a connected Material 3 Expressive button group.
Sourcepub fn variant(self, variant: ButtonGroupVariant) -> ButtonGroup
pub fn variant(self, variant: ButtonGroupVariant) -> ButtonGroup
Sets whether members are rendered as separate (Standard) or adjoining (Connected) buttons.
Sourcepub fn appearance(self, appearance: ButtonVariant) -> ButtonGroup
pub fn appearance(self, appearance: ButtonVariant) -> ButtonGroup
Sets the default ButtonVariant applied to group members.
Sourcepub fn tone(self, tone: SemanticTone) -> ButtonGroup
pub fn tone(self, tone: SemanticTone) -> ButtonGroup
Applies a default semantic tone across members and overflow menu items unless overridden per item.
Sourcepub fn size(self, size: ControlSize) -> ButtonGroup
pub fn size(self, size: ControlSize) -> ButtonGroup
Sets the ControlSize shared by all members and the overflow trigger.
Sourcepub fn selection(
self,
mode: ButtonGroupSelection,
selected: impl IntoIterator<Item = SharedString>,
) -> ButtonGroup
pub fn selection( self, mode: ButtonGroupSelection, selected: impl IntoIterator<Item = SharedString>, ) -> ButtonGroup
Configures caller-controlled selection mode and the currently selected item IDs.
Sourcepub fn on_change(
self,
callback: impl Fn(Vec<SharedString>, &mut Window, &mut App) + 'static,
) -> ButtonGroup
pub fn on_change( self, callback: impl Fn(Vec<SharedString>, &mut Window, &mut App) + 'static, ) -> ButtonGroup
Registers a callback invoked with the next list of selected item IDs when selection changes.
Sourcepub fn single_select(
self,
selected: impl Into<SharedString>,
on_select: impl Fn(SharedString, &mut Window, &mut App) + 'static,
) -> ButtonGroup
pub fn single_select( self, selected: impl Into<SharedString>, on_select: impl Fn(SharedString, &mut Window, &mut App) + 'static, ) -> ButtonGroup
Configures required single selection (ButtonGroupSelection::SingleRequired) and
delivers the newly selected item ID directly.
Sourcepub fn single_optional_select(
self,
selected: Option<SharedString>,
on_select: impl Fn(Option<SharedString>, &mut Window, &mut App) + 'static,
) -> ButtonGroup
pub fn single_optional_select( self, selected: Option<SharedString>, on_select: impl Fn(Option<SharedString>, &mut Window, &mut App) + 'static, ) -> ButtonGroup
Configures deselectable single selection (ButtonGroupSelection::Single) and
delivers the newly selected item ID, or None when the active option is cleared.
Sourcepub fn overflow_label(self, label: impl Into<SharedString>) -> ButtonGroup
pub fn overflow_label(self, label: impl Into<SharedString>) -> ButtonGroup
Sets the accessible name for the overflow menu trigger button. Defaults to "More actions".
Sourcepub fn shape(self, shape: ButtonShape) -> ButtonGroup
pub fn shape(self, shape: ButtonShape) -> ButtonGroup
Sets the base ButtonShape for standard button groups.
Sourcepub fn connected_shapes(self, shapes: ButtonGroupConnectedShapes) -> ButtonGroup
pub fn connected_shapes(self, shapes: ButtonGroupConnectedShapes) -> ButtonGroup
Overrides segment corner shapes for ButtonGroupVariant::Connected.
Sourcepub fn alignment(self, alignment: ContentArrangement) -> ButtonGroup
pub fn alignment(self, alignment: ContentArrangement) -> ButtonGroup
Sets the horizontal arrangement of visible members within the group row.
Sourcepub fn vertical_alignment(
self,
alignment: ButtonGroupVerticalAlignment,
) -> ButtonGroup
pub fn vertical_alignment( self, alignment: ButtonGroupVerticalAlignment, ) -> ButtonGroup
Sets the default vertical cross-axis alignment of members within the group row.
Sourcepub fn spacing(self, spacing: Pixels) -> ButtonGroup
pub fn spacing(self, spacing: Pixels) -> ButtonGroup
Overrides the horizontal gap between members in logical pixels.
Sourcepub fn expanded_ratio(self, ratio: f32) -> ButtonGroup
pub fn expanded_ratio(self, ratio: f32) -> ButtonGroup
Sets the press-expansion width ratio for ButtonGroupVariant::Standard members. Defaults to 0.15.
Sourcepub fn overflow_trigger<E>(
self,
width: Pixels,
content: impl FnOnce(bool) -> E + 'static,
) -> ButtonGroupwhere
E: IntoElement,
pub fn overflow_trigger<E>(
self,
width: Pixels,
content: impl FnOnce(bool) -> E + 'static,
) -> ButtonGroupwhere
E: IntoElement,
Supplies decorative content for the named overflow trigger.
Sourcepub fn overflow_content<E>(
self,
content: impl Fn() -> E + 'static,
) -> ButtonGroupwhere
E: IntoElement,
pub fn overflow_content<E>(
self,
content: impl Fn() -> E + 'static,
) -> ButtonGroupwhere
E: IntoElement,
Adds repeatable decorative content before the overflow rows.
Sourcepub fn overflow_open(self, open: bool) -> ButtonGroup
pub fn overflow_open(self, open: bool) -> ButtonGroup
Supplies the caller-owned open value for the overflow menu.
Sourcepub fn on_overflow_open_change(
self,
on_change: impl Fn(bool, &mut Window, &mut App) + 'static,
) -> ButtonGroup
pub fn on_overflow_open_change( self, on_change: impl Fn(bool, &mut Window, &mut App) + 'static, ) -> ButtonGroup
Registers a callback invoked when the overflow menu requests to open or close.
Trait Implementations§
Source§impl IntoElement for ButtonGroup
impl IntoElement for ButtonGroup
Source§type Element = ViewElement<ButtonGroup>
type Element = ViewElement<ButtonGroup>
Source§fn into_element(self) -> <ButtonGroup as IntoElement>::Element
fn into_element(self) -> <ButtonGroup as IntoElement>::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for ButtonGroup
impl RenderOnce for ButtonGroup
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for ButtonGroup
impl !Send for ButtonGroup
impl !Sync for ButtonGroup
impl !UnwindSafe for ButtonGroup
impl Forget for ButtonGroup
impl Freeze for ButtonGroupwhere
NonZero<u32>: Freeze,
&'static str: Freeze,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const ArcInner<Path> is !null: Freeze,
PhantomData<ArcInner<Path>>: Freeze,
*const str is !null: Freeze,
PhantomData<&'static str>: Freeze,
*const ArcInner<ElementId> is !null: Freeze,
PhantomData<ArcInner<ElementId>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<ButtonGroupItem>: Freeze,
PhantomData<SharedString>: Freeze,
*const RcInner<dyn Fn(Vec<SharedString>, &mut Window, &mut App)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(Vec<SharedString>, &mut Window, &mut App)>>: Freeze,
*const dyn FnOnce(bool) -> AnyElement is !null: Freeze,
PhantomData<dyn FnOnce(bool) -> AnyElement>: Freeze,
*const RcInner<dyn Fn() -> AnyElement> is !null: Freeze,
PhantomData<RcInner<dyn Fn() -> AnyElement>>: Freeze,
*const RcInner<dyn Fn(bool, &mut Window, &mut App)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(bool, &mut Window, &mut App)>>: Freeze,
impl Move for ButtonGroup
impl Unpin for ButtonGroupwhere
NonZero<u32>: Unpin,
&'static str: Unpin,
Arc<str>: Unpin,
Arc<Path>: Unpin,
*const str is !null: Unpin,
Arc<ElementId>: Unpin,
*const u8 is !null: Unpin,
Rc<dyn Fn(&mut Window, &mut App)>: Unpin,
Rc<dyn Fn(bool, &mut Window, &mut App)>: Unpin,
Rc<dyn Fn() -> AnyElement>: Unpin,
*const (): Unpin,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: Unpin,
Rc<dyn Fn(Vec<SharedString>, &mut Window, &mut App)>: Unpin,
Box<dyn FnOnce(bool) -> AnyElement>: Unpin,
impl UnsafeUnpin for ButtonGroupwhere
NonZeroU32Inner: UnsafeUnpin,
&'static str: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const ArcInner<Path> is !null: UnsafeUnpin,
PhantomData<ArcInner<Path>>: UnsafeUnpin,
*const str is !null: UnsafeUnpin,
PhantomData<&'static str>: UnsafeUnpin,
*const ArcInner<ElementId> is !null: UnsafeUnpin,
PhantomData<ArcInner<ElementId>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<ButtonGroupItem>: UnsafeUnpin,
PhantomData<SharedString>: UnsafeUnpin,
*const RcInner<dyn Fn(Vec<SharedString>, &mut Window, &mut App)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(Vec<SharedString>, &mut Window, &mut App)>>: UnsafeUnpin,
*const dyn FnOnce(bool) -> AnyElement is !null: UnsafeUnpin,
PhantomData<dyn FnOnce(bool) -> AnyElement>: UnsafeUnpin,
*const RcInner<dyn Fn() -> AnyElement> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn() -> AnyElement>>: UnsafeUnpin,
*const RcInner<dyn Fn(bool, &mut Window, &mut App)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(bool, &mut Window, &mut App)>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
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> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
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 moreSource§impl<T> MaterialElementExt for Twhere
T: IntoElement,
impl<T> MaterialElementExt for Twhere
T: IntoElement,
Source§fn badge_label(self, text: impl Into<SharedString>) -> Badge
fn badge_label(self, text: impl Into<SharedString>) -> Badge
Badge to this element’s upper trailing edge.Source§fn badge_count(self, count: usize, maximum: usize) -> Badge
fn badge_count(self, count: usize, maximum: usize) -> Badge
Badge to this element’s upper trailing edge.Source§fn tooltip(
self,
id: impl Into<ElementId>,
text: impl Into<SharedString>,
) -> Tooltip
fn tooltip( self, id: impl Into<ElementId>, text: impl Into<SharedString>, ) -> Tooltip
Tooltip.Menu.Menu
whose items are built lazily only while the menu is open.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<E> TestTextExt for Ewhere
E: IntoElement,
impl<E> TestTextExt for Ewhere
E: IntoElement,
Source§fn test_text(self, text: impl Into<SharedString>) -> ObservedText<Self::Element>
fn test_text(self, text: impl Into<SharedString>) -> ObservedText<Self::Element>
test-support, records text each time the element paints.
Otherwise returns the element it builds.Source§fn test_alt_text(
self,
text: impl Into<SharedString>,
) -> ObservedText<Self::Element>
fn test_alt_text( self, text: impl Into<SharedString>, ) -> ObservedText<Self::Element>
Self::test_text for an image’s alternative text, which
stands in for what the element draws.