pub struct ToggleButton { /* private fields */ }Implementations§
Source§impl ToggleButton
impl ToggleButton
Sourcepub fn key(self, key: impl Into<SharedString>) -> Self
pub fn key(self, key: impl Into<SharedString>) -> Self
Overrides the selection key, which otherwise mirrors the element id.
Sourcepub fn selection_key(&self) -> SharedString
pub fn selection_key(&self) -> SharedString
The member’s key inside a ToggleButtonGroup.
pub fn new(id: impl Into<ElementId>) -> Self
Sourcepub fn content(
self,
render: impl Fn(InteractiveState) -> AnyElement + 'static,
) -> Self
pub fn content( self, render: impl Fn(InteractiveState) -> AnyElement + 'static, ) -> Self
v3’s render function for the button’s children, handed isHovered,
isPressed, isFocused, isFocusVisible and isSelected. The hover and
the press are a frame behind the pointer – gpui reports both to a
handler, not to the render that draws them.
pub fn label(self, l: impl Into<SharedString>) -> Self
pub fn variant(self, v: ToggleVariant) -> Self
pub fn size(self, s: Size) -> Self
Sourcepub fn hover_bg(self, color: impl Into<Hsla>) -> Self
pub fn hover_bg(self, color: impl Into<Hsla>) -> Self
The fill the hover fade eases to, in place of the variant’s hover
colour. The fade runs from the resting background — the sx background
when one is set, the variant’s resting colour otherwise — so this is the
Button contract, on a toggle. v3 has no such prop.
Sourcepub fn radius(self, radius: impl Into<Pixels>) -> Self
pub fn radius(self, radius: impl Into<Pixels>) -> Self
The corner radius, in place of the owning control_radius helper.
Group edges, the hover fade and the press scale still apply. Not a v3
prop; the removed v2 radius prop is prohibited and this is a
per-component repository extension.
Sourcepub fn sx(self, style: impl FnOnce(Div) -> Div) -> Self
pub fn sx(self, style: impl FnOnce(Div) -> Div) -> Self
The one slot for caller-owned low-level styling: GPUI’s styling methods
(bg, text_color, w, h, p, rounded, border_color, …)
applied to the button’s root element after every value the variant, the
size and the active theme chose, so they win.
pub fn is_selected(self, v: bool) -> Self
Sourcepub fn default_selected(self, v: bool) -> Self
pub fn default_selected(self, v: bool) -> Self
defaultSelected — the uncontrolled initial state.
Only consulted when isSelected is not supplied; the button then owns
the state and toggles itself. A group always drives selection, so this
is for a standalone toggle.
pub fn is_icon_only(self, v: bool) -> Self
pub fn is_disabled(self, v: bool) -> Self
pub fn child(self, el: impl IntoElement) -> Self
Sourcepub fn on_change(
self,
f: impl Fn(&bool, &mut Window, &mut App) + 'static,
) -> Self
pub fn on_change( self, f: impl Fn(&bool, &mut Window, &mut App) + 'static, ) -> Self
onChange — reports the selection the press moves to.
Fires alongside ToggleButton::on_press; use whichever shape suits.
pub fn on_press( self, f: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, ) -> Self
Trait Implementations§
Source§impl IntoElement for ToggleButton
impl IntoElement for ToggleButton
Source§type Element = ViewElement<ToggleButton>
type Element = ViewElement<ToggleButton>
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl ParentElement for ToggleButton
impl ParentElement for ToggleButton
Source§fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>)
fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>)
Source§fn child(self, child: impl IntoElement) -> Selfwhere
Self: Sized,
fn child(self, child: impl IntoElement) -> Selfwhere
Self: Sized,
Source§fn children(self, children: impl IntoIterator<Item = impl IntoElement>) -> Selfwhere
Self: Sized,
fn children(self, children: impl IntoIterator<Item = impl IntoElement>) -> Selfwhere
Self: Sized,
Source§impl RenderOnce for ToggleButton
impl RenderOnce for ToggleButton
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 ToggleButton
impl !Send for ToggleButton
impl !Sync for ToggleButton
impl !UnwindSafe for ToggleButton
impl Freeze for ToggleButton
impl Unpin for ToggleButton
impl UnsafeUnpin for ToggleButton
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 more