Skip to main content

WidgetExt

Trait WidgetExt 

Source
pub trait WidgetExt: Widget + Sized {
    // Provided methods
    fn padding(self, padding: Padding) -> Padded<Self> { ... }
    fn margin(self, margin: Margin) -> Margined<Self> { ... }
    fn background(self, background: Color) -> Backgrounded<Self> { ... }
    fn border(self, border: Border) -> Bordered<Self> { ... }
    fn on_click(
        self,
        label: impl Into<String>,
        callback: impl FnMut() + 'static,
    ) -> OnClick<Self> { ... }
    fn on_hover(
        self,
        label: impl Into<String>,
        callback: impl FnMut(bool) + 'static,
    ) -> OnHover<Self> { ... }
}
Expand description

Chainable decorators for any Widget.

Blanket-implemented for every Widget, so my_widget.padding(p).border(b) works without per-type impls. Each method consumes self and returns a wrapper that still implements Widget.

Provided Methods§

Source

fn padding(self, padding: Padding) -> Padded<Self>

Wrap with Padding.

Source

fn margin(self, margin: Margin) -> Margined<Self>

Wrap with Margin.

Source

fn background(self, background: Color) -> Backgrounded<Self>

Wrap with a background Color.

Source

fn border(self, border: Border) -> Bordered<Self>

Wrap with a Border.

Source

fn on_click( self, label: impl Into<String>, callback: impl FnMut() + 'static, ) -> OnClick<Self>

Attach a click callback, surfaced through a companion button labelled label.

Source

fn on_hover( self, label: impl Into<String>, callback: impl FnMut(bool) + 'static, ) -> OnHover<Self>

Attach a hover callback, surfaced through a companion button labelled label.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<W: Widget> WidgetExt for W