Skip to main content

button_labelled

Function button_labelled 

Source
pub fn button_labelled(label: View, action: impl Fn() + 'static) -> View
Expand description

Button { action } label: { … } — a button whose label is a view rather than a string.

Examples found in repository?
examples/todo.rs (lines 63-69)
59fn row(i: usize, it: &Item) -> View {
60    hstack_spacing(
61        &[
62            // The checkmark is the button, so the whole symbol is the target.
63            button_labelled(
64                system_image(if it.done { "checkmark.circle.fill" } else { "circle" })
65                    .symbol_rendering_mode(Some(views::SymbolRenderingMode::Hierarchical))
66                    .view()
67                    .fg_system(if it.done { SystemColor::Green } else { SystemColor::Gray }),
68                move || toggle(i),
69            )
70            .button_style(views::ButtonStyle::Bordered),
71            text(&it.title)
72                .strikethrough_styled(it.done, LinePattern::Solid, None)
73                .fg_system(if it.done { SystemColor::Gray } else { SystemColor::Primary }),
74            spacer(),
75        ],
76        10.0,
77    )
78    .padding_edges(EdgeSet::Vertical, Some(6.0))
79    .a11y_label(&it.title)
80    .a11y_value(if it.done { "Done" } else { "Not done" })
81}