pub struct Button { /* private fields */ }Expand description
Button widget
Buttons can have custom content via button_with() or use the simple
button("Label") constructor for text-only buttons.
The element is made when it is first asked for, so every fluent call made before that counts, in any order.
Implementations§
Source§impl Button
impl Button
Sourcepub fn new(label: impl IntoReactive<String>) -> Button
pub fn new(label: impl IntoReactive<String>) -> Button
Create a button with a text label.
The label can follow a signal; it is patched in place.
Sourcepub fn with_content<F, E>(content: F) -> Button
pub fn with_content<F, E>(content: F) -> Button
Create a button holding the element content returns.
content is called once, when the button is built. It does not run
again when the pointer state changes: text and icons inside take the
button’s color as it changes.
Sourcepub fn key(self, key: impl Into<String>) -> Button
pub fn key(self, key: impl Into<String>) -> Button
Name the button’s pointer state, so it persists across rebuilds under a key of your choosing instead of one made from where it was created. Needed for buttons made in a loop from one place.
Sourcepub fn style(self, style: &ElementStyle) -> Button
pub fn style(self, style: &ElementStyle) -> Button
Apply an ElementStyle to the button’s element as its default tier,
below an application stylesheet and below any fluent call made after
it. Replayed in call order with the other fluent calls.
Sourcepub fn bg_color(self, color: impl Into<Color>) -> Button
pub fn bg_color(self, color: impl Into<Color>) -> Button
The fill, in every state: a fluent value wins over the default look’s rules, so this fixes the fill. To restyle by state, write rules.
Sourcepub fn text_color(self, color: impl Into<Color>) -> Button
pub fn text_color(self, color: impl Into<Color>) -> Button
Colour of the label of a button made with button("Label"). For custom
content, give the content’s own text a colour or set color in a rule.
Sourcepub fn text_size(self, size: f32) -> Button
pub fn text_size(self, size: f32) -> Button
Set text size for simple text buttons created with button("Label")
Note: This has no effect on buttons created with button_with().
Sourcepub fn disabled(self, disabled: impl IntoReactive<bool>) -> Button
pub fn disabled(self, disabled: impl IntoReactive<bool>) -> Button
Disable the button, for good or while a signal holds. A disabled
button matches :disabled and does not click.
pub fn on_click<F>(self, handler: F) -> Button
Source§impl Button
impl Button
pub fn px(self, v: f32) -> Button
pub fn py(self, v: f32) -> Button
pub fn p(self, v: f32) -> Button
pub fn pt(self, v: f32) -> Button
pub fn pb(self, v: f32) -> Button
pub fn pl(self, v: f32) -> Button
pub fn pr(self, v: f32) -> Button
pub fn rounded(self, v: f32) -> Button
pub fn border(self, width: f32, color: Color) -> Button
pub fn border_color(self, color: Color) -> Button
pub fn border_width(self, width: f32) -> Button
pub fn w(self, v: f32) -> Button
pub fn h(self, v: f32) -> Button
pub fn w_full(self) -> Button
pub fn h_full(self) -> Button
pub fn w_fit(self) -> Button
pub fn h_fit(self) -> Button
pub fn mt(self, v: f32) -> Button
pub fn mb(self, v: f32) -> Button
pub fn ml(self, v: f32) -> Button
pub fn mr(self, v: f32) -> Button
pub fn mx(self, v: f32) -> Button
pub fn my(self, v: f32) -> Button
pub fn m(self, v: f32) -> Button
pub fn gap(self, v: f32) -> Button
pub fn items_center(self) -> Button
pub fn items_start(self) -> Button
pub fn items_end(self) -> Button
pub fn justify_center(self) -> Button
pub fn justify_start(self) -> Button
pub fn justify_end(self) -> Button
pub fn justify_between(self) -> Button
pub fn flex_row(self) -> Button
pub fn flex_col(self) -> Button
pub fn flex_grow(self) -> Button
pub fn flex_shrink(self) -> Button
pub fn flex_shrink_0(self) -> Button
pub fn shadow_sm(self) -> Button
pub fn shadow_md(self) -> Button
pub fn shadow_lg(self) -> Button
pub fn shadow_xl(self) -> Button
pub fn opacity(self, v: f32) -> Button
Trait Implementations§
Source§impl ElementBuilder for Button
impl ElementBuilder for Button
Source§fn build(&self, tree: &mut LayoutTree) -> LayoutNodeId
fn build(&self, tree: &mut LayoutTree) -> LayoutNodeId
Source§fn render_props(&self) -> RenderProps
fn render_props(&self) -> RenderProps
Source§fn children_builders(&self) -> &[Box<dyn ElementBuilder>]
fn children_builders(&self) -> &[Box<dyn ElementBuilder>]
Source§fn element_type_id(&self) -> ElementTypeId
fn element_type_id(&self) -> ElementTypeId
Source§fn semantic_type_name(&self) -> Option<&'static str>
fn semantic_type_name(&self) -> Option<&'static str>
Source§fn element_classes(&self) -> &[Arc<str>]
fn element_classes(&self) -> &[Arc<str>]
Source§fn event_handlers(&self) -> Option<&EventHandlers>
fn event_handlers(&self) -> Option<&EventHandlers>
Source§fn as_any(&self) -> Option<&(dyn Any + 'static)>
fn as_any(&self) -> Option<&(dyn Any + 'static)>
Source§fn text_render_info(&self) -> Option<TextRenderInfo>
fn text_render_info(&self) -> Option<TextRenderInfo>
Source§fn styled_text_render_info(&self) -> Option<StyledTextRenderInfo>
fn styled_text_render_info(&self) -> Option<StyledTextRenderInfo>
Source§fn svg_render_info(&self) -> Option<SvgRenderInfo>
fn svg_render_info(&self) -> Option<SvgRenderInfo>
Source§fn image_render_info(&self) -> Option<ImageRenderInfo>
fn image_render_info(&self) -> Option<ImageRenderInfo>
Source§fn canvas_render_info(
&self,
) -> Option<Rc<dyn Fn(&mut dyn DrawContext, CanvasBounds)>>
fn canvas_render_info( &self, ) -> Option<Rc<dyn Fn(&mut dyn DrawContext, CanvasBounds)>>
Source§fn is_static_canvas(&self) -> bool
fn is_static_canvas(&self) -> bool
render_fn produces deterministic output
for a given bounds + closure captures, with no per-frame state
(animations, timers, live signal reads). Static canvases get
emitted to the bg batch normally but skip the per-frame
overlay re-paint that would otherwise overdraw any children
the walker layered on top of them in the static cache. They
also don’t flip the had_canvas_painted gate, so the
compositor fast path can still engage on frames where the
only canvases are static. Read moreSource§fn canvas_redraw_while(&self) -> Option<Rc<dyn Fn() -> bool>>
fn canvas_redraw_while(&self) -> Option<Rc<dyn Fn() -> bool>>
crate::canvas::Canvas::redraw_while. Applies only when
element_type_id is ElementTypeId::Canvas.Source§fn effective_layout_style(&self) -> Option<Style>
fn effective_layout_style(&self) -> Option<Style>
Style that this element actually installs on its
layout node — i.e. the style after any widget-internal
adjustments build() would apply. The default delegates to
layout_style().cloned(), which is correct for elements
whose build() just forwards self.style verbatim. Override
when build() mutates the style before handing it to taffy
(e.g. Notch::build adds scoop.depth to padding so children
don’t render over the carved-out region). Read moreSource§fn scroll_info(&self) -> Option<ScrollRenderInfo>
fn scroll_info(&self) -> Option<ScrollRenderInfo>
Source§fn scroll_physics(&self) -> Option<Arc<Mutex<ScrollPhysics>>>
fn scroll_physics(&self) -> Option<Arc<Mutex<ScrollPhysics>>>
Source§fn viewport_cull(&self) -> bool
fn viewport_cull(&self) -> bool
Source§fn motion_animation_for_child(
&self,
_child_index: usize,
) -> Option<MotionAnimation>
fn motion_animation_for_child( &self, _child_index: usize, ) -> Option<MotionAnimation>
Source§fn motion_bindings(&self) -> Option<MotionBindings>
fn motion_bindings(&self) -> Option<MotionBindings>
Source§fn motion_stable_id(&self) -> Option<&str>
fn motion_stable_id(&self) -> Option<&str>
Source§fn motion_should_replay(&self) -> bool
fn motion_should_replay(&self) -> bool
Source§fn motion_is_suspended(&self) -> bool
fn motion_is_suspended(&self) -> bool
Source§fn motion_is_exiting(&self) -> bool
fn motion_is_exiting(&self) -> bool
Use query_motion(key).exit() to explicitly trigger motion exit
Source§fn layout_bounds_storage(&self) -> Option<Arc<Mutex<Option<ElementBounds>>>>
fn layout_bounds_storage(&self) -> Option<Arc<Mutex<Option<ElementBounds>>>>
Source§fn layout_bounds_callback(
&self,
) -> Option<Arc<dyn Fn(ElementBounds) + Send + Sync>>
fn layout_bounds_callback( &self, ) -> Option<Arc<dyn Fn(ElementBounds) + Send + Sync>>
Source§fn set_auto_id(&mut self, _id: String) -> bool
fn set_auto_id(&mut self, _id: String) -> bool
Source§fn children_builders_mut(&mut self) -> &mut [Box<dyn ElementBuilder>]
fn children_builders_mut(&mut self) -> &mut [Box<dyn ElementBuilder>]
Source§fn bound_scroll_ref(&self) -> Option<&ScrollRef>
fn bound_scroll_ref(&self) -> Option<&ScrollRef>
Source§fn bound_element_ref(&self) -> Option<&DivRef>
fn bound_element_ref(&self) -> Option<&DivRef>
crate::selector::DivRef, if the builder was
given one. The renderer resolves it to this element’s node.Source§fn motion_on_ready_callback(
&self,
) -> Option<Arc<dyn Fn(ElementBounds) + Send + Sync>>
fn motion_on_ready_callback( &self, ) -> Option<Arc<dyn Fn(ElementBounds) + Send + Sync>>
Source§fn layout_animation_config(&self) -> Option<LayoutAnimationConfig>
fn layout_animation_config(&self) -> Option<LayoutAnimationConfig>
Source§fn visual_animation_config(&self) -> Option<VisualAnimationConfig>
fn visual_animation_config(&self) -> Option<VisualAnimationConfig>
Auto Trait Implementations§
impl !Freeze for Button
impl !RefUnwindSafe for Button
impl !Send for Button
impl !Sync for Button
impl !UnwindSafe for Button
impl Unpin for Button
impl UnsafeUnpin for Button
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
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.